Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.symlink casues strange errors - EISDIR, EPERM, EEXIST #8920

Closed
crackcomm opened this issue Dec 22, 2014 · 3 comments
Closed

fs.symlink casues strange errors - EISDIR, EPERM, EEXIST #8920

crackcomm opened this issue Dec 22, 2014 · 3 comments
Labels

Comments

@crackcomm
Copy link

  • README.md exists
  • tmp is empty directory
  • at the end no symlink was created
  • fs.symlink and fs.symlinkSync are affected
  • node is running with Administrator rights
  • Windows 7
  • node v0.10.x, node v0.11.14
  • works fine with MinGW
> fs.symlinkSync('README.md', 'tmp/README.md', 'file')
Error: EISDIR, illegal operation on a directory 'D:\cc\ui-7\tmp\README.md'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:767:18)
    at repl:1:4
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:206:10)
    at REPLServer.Interface._line (readline.js:535:8)
> fs.symlinkSync('README.md', 'tmp/README.md', 'dir')
Error: EISDIR, illegal operation on a directory 'D:\cc\ui-7\tmp\README.md'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:767:18)
    at repl:1:4
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:206:10)
    at REPLServer.Interface._line (readline.js:535:8)
> fs.symlinkSync('README.md', 'tmp/', 'file')
Error: EPERM, operation not permitted 'README.md'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:767:18)
    at repl:1:4
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:206:10)
    at REPLServer.Interface._line (readline.js:535:8)
> fs.symlinkSync('README.md', 'tmp/', 'dir')
Error: EEXIST, file already exists 'README.md'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:767:18)
    at repl:1:4
    at REPLServer.defaultEval (repl.js:133:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:280:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:206:10)
    at REPLServer.Interface._line (readline.js:535:8)
@piscisaureus
Copy link

I agree that the error codes are weird, and I think I know why. But first:

  • What filesystem is d:\ ?

README.md exists

  • That's laregely irrelevant. What you're doing here is create a symlink from tmp/README.md to tmp/README.md.

works fine with MinGW

  • What do you mean? How did you test this?

@crackcomm
Copy link
Author

What filesystem is d:\ ?

NTFS

That's laregely irrelevant. What you're doing here is create a symlink from tmp/README.md to tmp/README.md.

No. What I'm doing here is create a symlink from README.md to tmp/README.md.

What do you mean? How did you test this?

I launched node from msys console.

@piscisaureus
Copy link

No. What I'm doing here is create a symlink from README.md to tmp/README.md.

Right, I think the docs are wrong. What's happening is that you're creating a symlink called tmp/README.md which contains README.md. The argument order is the same as the symlink(3) syscall.

I launched node from msys console.

I find that very curious, because it shouldn't have any influence and I can't think of any mechanism that could cause it. I think that if you'd try exactly the same again from msys it would fail in the same way.

So what we're seeing:

  • The docs are wrong
  • The error codes are not appropriate, and in the EEXIST/EPERM case they mention the wrong path (should mention the second component, not the first).

piscisaureus added a commit to piscisaureus/node that referenced this issue Dec 23, 2014
The offending doc change clarified nothing, but put the arguments to
fs.symlink() and fs.symlinkSync() in the wrong order.

This reverts commit 8146f2e.

BUG: nodejs#8920
@piscisaureus piscisaureus self-assigned this Dec 23, 2014
@piscisaureus piscisaureus removed their assignment Dec 24, 2014
piscisaureus added a commit to nodejs/node that referenced this issue Jan 27, 2015
The offending doc change clarified nothing, but put the arguments to
fs.symlink() and fs.symlinkSync() in the wrong order.

This reverts commit 8146f2e.

BUG: nodejs/node-v0.x-archive#8920
PR: nodejs/node-v0.x-archive#8936
@jasnell jasnell added the fs label Jun 25, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants