ben-eb/gulp-symlink

Windows relative symlinks falling back to junction don't work.

BSick7 opened this issue · 7 comments

If a windows symlink fails (usually because of non-admin terminal), gulp-symlink falls back to using junctions. However, if trying to create a relative symlink, this will fail for junctions as well (http://ss64.com/nt/mklink.html).

A nicer error message would help diagnose this issue. Perhaps, if there is a permission issue and relative, report just that: "Relative symlinks require admin privileges."

I can't test on Windows (beyond running CI) so I would appreciate any help on this.

I think I might be running into this issue.

@BSick7 Does this mean if I do this .pipe(symlink('../../.git/hooks/pre-commit', {force: true}));, it will break for Windows?

@jdaudier I can't confirm this, but it appears that symlink creates a relative symlink by default. This would break on windows if the command is not run in an admin context.

@BSick7 Can you explain what you mean by if the command is not run in an admin context? Noob question, sorry.

@jdaudier By default, a new command prompt is not run under admin rights. Usually, a user has to right click on command prompt and click Run as Administrator.

Since

  • This is a gulp plugin and there's basically no justification for ever wanting to run gulp as an administrator
  • The 'type' argument for fs.symlink is ignored on platforms other than windows
  • Directory junctions are essentially equivalent to directory symlinks (except in exotic cases like crossing remote filesystems)

…I would recommend that this gulp plugin, in order to be cross-platform, should:

  • Only support directories, not files
  • Always specify 'junction' as the type (instead of 'file' or 'directory')