1

This is a Symfony PHP Framework's bin/ directory, output for ls -la
For some reason it is showing a bash script instead of a filename. The Linux version is Debian Stretch.

ls is showing some bash script for the dead symlink instead of a filename

This is the result of the php composer.phar update command run through Atlassian Pipelines script. If the same command is is run manually, everything is OK. The relevant part of the bitbucket-pipelines.yml looks like

pipelines:
  custom:
    manual_preprod:
      - step:
          script:
            - ssh $PREPROD_USER@$PREPROD_HOST -t "cd ${FULLPATH} && php composer.phar update"

I suppose there is a bug in php composer that makes it to provide a file contents instead of a file name when creating symlink? How it's even possible?

The code appears to be from one of composer's scripts, BinaryInstaller.php

Edit:

Looks like it's a git + Windows to Linux issue.

These files were added to git repo on Windows, and under that system are just regular files with the content such as

#!/usr/bin/env sh
dir=$(d=\${0%[/\\\\]*}; cd "\$d" > /dev/null; cd $binDir && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
    # Cygwin paths start with /cygdrive/ which will break windows PHP,
    # so we need to translate the dir path to windows format. However
    # we could be using cygwin PHP which does not require this, so we
    # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
    if [[ $(which php) == /cygdrive/* ]]; then
        dir=$(cygpath -m "\$dir");
    fi
fi

after git pull command issued on Debian Stretch, these files become such weird symlinks from the above, the content become a filename of the target file.

  • They keep the script in a variable (why?!) and the symbolic link filename in another, and then accidentally use the wrong variable in the call to ln -s, possibly? – Kusalananda Feb 6 '18 at 15:32
  • Note that this command works flawlessly when called manually, only making this mess when called though a pipelines script – Your Common Sense Feb 6 '18 at 15:35
  • @JeffSchaller I was looking for the code and finally found it, added the link to the file. It appears to be no the last version though so updating and trying to reproduce right now. – Your Common Sense Feb 6 '18 at 16:11
  • @JeffSchaller Are you running Cygwin perchance? Have you had any difficulties with creating symbolic links before? What about links across filesystems? – Alhadis Feb 6 '18 at 16:32
  • @JeffSchaller I've updated my answer. Check what git config core.symlinks has to say when run from your repository. – Alhadis Feb 10 '18 at 10:31
2

You sound like you have core.symlinks set to false in your .gitconfig (either globally or local to your repository). From git-config(1):

core.symlinks
If false, symbolic links are checked out as small plain files that contain the link text. git‑update‑index(1) and git‑add(1) will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links.

The default is true, except git-clone(1) or git-init(1) will probe and set core.symlinks false if appropriate when the repository is created.

You can check the setting's status by running:

git config core.editor
  • Looks like these files were added to git, and were committed from Windows system and then fetched on Linux. – Your Common Sense Feb 7 '18 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.