Skip to content
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

Force symbolic link (ln -sf) does not overwrite/recreate existing destination #830

Closed
SeanSnyders opened this issue Apr 3, 2018 · 4 comments

Comments

@SeanSnyders
Copy link

Node version (or tell us if you're using electron or some other framework):

8.11.1

npm version (or tell us if you're using electron or some other framework):

5.6.0

ShellJS version (the most recent version/Github branch you see the bug on):

0.7.7 and 0.8.1

Operating system:

ubuntu 14.04

Description of the bug:

On ubuntu the symlink command ln -sf seems to not force the link if the destination exists. Seems to work fine on macOS.

image

Example ShellJS command to reproduce the error:

On linux:

var shell = require('shelljs');
shell.ln('-sf', "source", "link");
@nfischer
Copy link
Member

nfischer commented Apr 3, 2018

Possibly related to #829?

@SeanSnyders could you give a more complete example? It's not clear what source and link are supposed to be in your example. If one of those is supposed to be a pre-existing file, could you include the sample code which creates that?

When I run your script, I get:

ln: Source file does not exist

Which makes sense, because I don't have source on my disk.

@SeanSnyders
Copy link
Author

Not sure if it is related to #829 because it works for me on macOS.

Yes, source and link are example folder names. It is not intended to run as-is on your machine.
The source being the folder to link to, and link being the link you are trying to create (typical ln semantics: see man ln)
And of course I cannot give you an exact code example as it depends on exact folders being present on your machine as to mine, which is not possible.

The error is as I described when trying to run shell.ln with the dest parameter a path that is already a valid symbolic link. In other words, I am trying to replace my existing symbolic link with a new one thus using the force -f flag.

@nfischer
Copy link
Member

nfischer commented Apr 3, 2018

because it works for me on macOS.

I'm not sure what "it" is. What works on macOS? Does that same thing not work on Linux or some other OS?

depends on exact folders being present on your machine as to mine, which is not possible.

Or you could write a script which creates those precondition folders/files/symlinks 😄 ln('-sf', 'source', 'link') is obviously not clear enough: you're just quoting the docs for how to use ln(), not explaining the issue.

I'm happy to investigate the issue, but it helps to have a script I can run in an empty working directory to reproduce the problem (and so that I can compare against unix behavior).

@nfischer
Copy link
Member

In other words, I am trying to replace my existing symbolic link with a new one thus using the force -f flag.

I tried once more today to repro (on Linux). Specifically:

  • try overwriting a valid symlink to a file with a symlink (it works)
  • try overwriting a valid symlink to a directory with a symlink (it works)

I'm closing this because I can't repro. @SeanSnyders please ping this thread if you still see the issue, and if possible, please provide more clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants