-
Notifications
You must be signed in to change notification settings - Fork 774
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
createSymlink
fails when ensuring a symbolic link with a relative path if the link already exists
#1038
Comments
reference to bug submission jprichardson/node-fs-extra#1038 [skip ci]
Good catch, that's definitely a bug. BTW, I appreciate your clearly-written issue; it has all the information I need, and none of the information I don't. It's a breath of fresh air; if everyone filed issues like this, my job as an open-source maintainer would be much easier. Just thought it's worthy of a shout-out. Looks like node-fs-extra/lib/ensure/symlink.js Lines 58 to 67 in 426bb46
It seems like the simplest fix would be to If you want to take a stab at a PR, that'd be welcome; otherwise, I'll try to get to this myself in the coming week or two. |
Glad to be of service. I will not be taking a stab at a PR at this time. I'm trying to make progress on my own thing (https://bitbucket.org/toryt/git-backup) during my holiday, where I've worked around the issue for now, so, as far as I’m concerned, take your time. Just be sure not to include any backdoors in here :-). |
Hi, I just encountered the same issue. I tried to upgrade to |
Found an alternative before this is fixed: downgrade to |
fs-extra
version: 11.2.0Issue
This works if the reference to the
target
is an absolute path, but fails if the reference is a relative path.Example
This is a
mocha
test that shows the issue. The first test ensures the symbolic link a second time with an absolute path, which succeeds as expected. The second test ensures the symbolic link a second time with a relative path, which is rejected withENOENT
, but should succeed too.Analysis
The issue is clear in
fs-extra/lib/ensure/symlink.js
, line 24, versus line 32.When there is no symbolic link yet at
dstpath
, theif
of line 22 is skippedand we arrive at line 31—32 where work is done to deal with relative
srcpath
s:When there is a symbolic link at
dstpath
, theif
–branch at line 22 is executed. Here, the status of thesrcpath
is requested as is:This evaluates a relative
srcpath
relative to thecwd
, not to thedstpath
. At that location the source does not exist, which results inENOENT
.The text was updated successfully, but these errors were encountered: