New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken symlinks can't be copied #658

Closed
bltavares opened this Issue Mar 7, 2014 · 9 comments

Comments

Projects
None yet
5 participants
@bltavares

bltavares commented Mar 7, 2014

Hi there,

I wanted to package the project directory under /usr/local/share/project and have a symlink on /usr/local/bin/project -> /usr/local/share/project/bin/project.
The link is broken on the packager system, but would resolve to the right location when installed.

Steps to reproduce

mkdir project
cd project

echo "echo 1" > sample-command
ln -s /usr/local/share/project/sample-command project-bin
fpm -s dir -t deb -n project .=/usr/local/share/project project-bin=/usr/local/bin

Error message

Invalid package configuration: Cannot package the path 'project-bin', does it exist? {:level=>:error}

Version

fpm (1.0.2)

@terrorobe

This comment has been minimized.

terrorobe commented Jul 18, 2014

This is caused by the following check:

if File.file?(source) && !File.directory?(destination)

Expanding it to

    if (File.file?(source) || File.symlink?(source)) && !File.directory?(destination)

seems to work, but I don't know if anything else will explode with that change.

This is caused by Ruby's questionable File test behaviour when it comes to symlinks:

deploy@web02:~/build$ ln -s /tmp/linktarget linktest
deploy@web02:~/build$ ls -la /tmp/linktarget
ls: cannot access /tmp/linktarget: No such file or directory
deploy@web02:~/build$ ruby -e "puts File.file?('linktest')" 
false
deploy@web02:~/build$ touch /tmp/linktarget
deploy@web02:~/build$ ruby -e "puts File.file?('linktest')" 
true
deploy@web02:~/build$ 
@terrorobe

This comment has been minimized.

terrorobe commented Jul 18, 2014

Also reported upstream: https://bugs.ruby-lang.org/issues/10067

@oleyka

This comment has been minimized.

oleyka commented Oct 24, 2014

and it's still an issue as of fpm version 1.2.0...

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Oct 24, 2014

Confirmed -

% ln -sf /nonexistant/path/here /tmp/foo
% fpm -s dir -t deb -n example /tmp/foo
Invalid package configuration: Cannot package the path './tmp/foo', does it exist? {:level=>:error}

@jordansissel jordansissel added the bug label Oct 24, 2014

@jordansissel jordansissel self-assigned this Oct 24, 2014

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Oct 25, 2014

Fix should appear in the next release.

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Oct 25, 2014

@oleyka thanks for the reminder that this still wasn't fixed!

Also thanks to all who reported and helped reproduce it. Our powers combined == better fpm!

@bltavares

This comment has been minimized.

bltavares commented Oct 25, 2014

Thank you for fixing it @jordansissel (:

@oleyka

This comment has been minimized.

oleyka commented Oct 27, 2014

@jordansissel thanks for the prompt fix. Love your product and support!

This was referenced Dec 9, 2014

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014

jls
Don't follow symlinks when copying files.
Added test coverage to ensure a broken symlink doesn't throw a ENOENT
error. The test was written first, and failed, but now passes with the
fix to the dir package.

Fixes jordansissel#658

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 27, 2014

Don't follow symlinks when copying files.
Added test coverage to ensure a broken symlink doesn't throw a ENOENT
error. The test was written first, and failed, but now passes with the
fix to the dir package.

Fixes jordansissel#658

jordansissel added a commit that referenced this issue Apr 24, 2015

Don't follow symlinks when copying files.
Added test coverage to ensure a broken symlink doesn't throw a ENOENT
error. The test was written first, and failed, but now passes with the
fix to the dir package.

Fixes #658
@alanthing

This comment has been minimized.

Contributor

alanthing commented Mar 2, 2016

I don't have a PR, but I noticed this bug when using the virtualenv source type if the contents of my --virtualenv-other-files-dir . contains a broken symlink. My workaround is to simply touch the "target" on the the build server.

jordansissel added a commit that referenced this issue Jun 20, 2016

Don't follow symlinks when copying files.
Added test coverage to ensure a broken symlink doesn't throw a ENOENT
error. The test was written first, and failed, but now passes with the
fix to the dir package.

Fixes #658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment