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

fs.renameSync reports that source does not exist when destination does not exist #5742

Closed
FabianFrank opened this issue Jun 25, 2013 · 5 comments
Labels

Comments

@FabianFrank
Copy link

Here, we use a 3 level relative path and our source clearly exists:

frankfa@palmtree:~/tmp/rename (1) $ nvm use v0.10.12
Now using node v0.10.12
frankfa@palmtree:~/tmp/rename (0) $
frankfa@palmtree:~/tmp/rename (0) $ rm -rf a && mkdir A && node
> var fs=require('fs'); fs.renameSync('A', 'a/b/c');
Error: ENOENT, no such file or directory 'A'
    at Object.fs.renameSync (fs.js:543:18)
    at repl:1:26
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

If we use a 2 level paths, it also gets quite weird:

> var fs=require('fs'); fs.renameSync('A', 'a/b');
Error: EINVAL, invalid argument 'A'
    at Object.fs.renameSync (fs.js:543:18)
    at repl:1:26
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

And now for bonus points, 3 levels

> var fs=require('fs'); fs.renameSync('A', 'a/b/c/d');
Error: ENOENT, no such file or directory 'A'
    at Object.fs.renameSync (fs.js:543:18)
    at repl:1:26
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

If the destination exists, we are good

> var fs=require('fs'); fs.renameSync('A', 'a');
undefined
@thomasdavis
Copy link

ahh pretty sure I've run into this, what a night mare bug lol

@indutny
Copy link
Member

indutny commented Apr 21, 2014

Have you tried the latest v0.10 node?

@thomasdavis
Copy link

Will do, spent about 3 hours on this bug before finding the same result as OP.

@faridnsh
Copy link

faridnsh commented Dec 8, 2014

I think this is a duplicate of #685

@jasnell
Copy link
Member

jasnell commented May 26, 2015

Closing. Duplicate.

@jasnell jasnell closed this as completed May 26, 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

5 participants