You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows. Incorrect Module.id with mounted network disk #7294
b488b19 is responsible for this - it changed how fs.realpath works. It landed in v6.
At the same time change to how modules filenames are resolved was introduced in de1dc0a. It switched from fs.realpath to path.resolve. Those two changes together made module filenames resolve as before realpath implementation change.
Now 5d38d54 put change from fs.realpath to path.resolve behind --preserve-symlinks switch. And so, instead of having this issue with v6.0, with fs.realpath change, we have it now. It is just another effect of fs.realpath change which is documented as breaking.
I don't know if we should fix this. Old realpath implementation on Windows didn't check if the drive itself is a "symlink" - mapped network share or effect of callingsubst. IMHO current implementation is correct. If needed, one can use --preserve-symlinks to make modules file name resolve as they used to before. Alternatively, one can use require.resolve to get the filename used as keys to require.cache.
Of course, we could also try to fix this. For Windows, we could make require fall back to old realpath implementation if new one gives filename on different drive or on a network share. The question is, should we do this?
My situation is even worse, if possible. I'm using Visual Studio Code to develop and debug node projects.
I frequently switch project, so to simplify my workflow I use subst to make the root of the project act like a disk drive: this makes path shorter (with the side effect of reducing the Windows long path problem) and allows me to quickly change project simply by typing the drive letter.
I recently upgraded to node v6.3.0 and I can't set breakpoint in VS Code anymore, because the modules are loaded with their 'real' path instead of the substituted one. --preserve-symlinks doesn't resolve the situation: the main file loading ignores the flag and because all subsequent require use a relative path all the files are loaded with the real path, making impossible setting breakpoints (that needs the absolute path of the file)
Activity
mscdex commentedon Jun 13, 2016
Can you launch node with
--preserve-symlinksand try again? I suspect 95b7560 is the culprit.tsofist commentedon Jun 13, 2016
Yes, with
--preserve-symlinksit works correctlymscdex commentedon Jun 14, 2016
/cc @jasnell
joshgav commentedon Jun 14, 2016
/cc @orangemocha
tsofist commentedon Jun 19, 2016
I found similar problem with
__filenameand__dirname.node v6.1.0 (and previous):
V:\scope\main.jsnode v6.2.0 (and v6.2.1):
\\CASTOR\scope\main.jsShould I write a new issue for this?
bzoz commentedon Jun 22, 2016
b488b19 is responsible for this - it changed how
fs.realpathworks. It landed in v6.At the same time change to how modules filenames are resolved was introduced in de1dc0a. It switched from
fs.realpathtopath.resolve. Those two changes together made module filenames resolve as before realpath implementation change.Now 5d38d54 put change from
fs.realpathtopath.resolvebehind--preserve-symlinksswitch. And so, instead of having this issue with v6.0, withfs.realpathchange, we have it now. It is just another effect offs.realpathchange which is documented as breaking.I don't know if we should fix this. Old
realpathimplementation on Windows didn't check if the drive itself is a "symlink" - mapped network share or effect of callingsubst. IMHO current implementation is correct. If needed, one can use--preserve-symlinksto make modules file name resolve as they used to before. Alternatively, one can userequire.resolveto get the filename used as keys torequire.cache.Of course, we could also try to fix this. For Windows, we could make
requirefall back to oldrealpathimplementation if new one gives filename on different drive or on a network share. The question is, should we do this?tsofist commentedon Jun 22, 2016
I wrote this module (
t.js):Run node from
V:\Work\IDEA\projects\efrond\nas\~mount from\\CASTOR-VSRV\Development\Work\IDEA\projects\efrond\nas\~Output
node v5.9.1:
node v6.0.0:
node v6.2.1:
node v6.2.1 --preserve-symlinks:
I do not think it's ok.
Information about the module becomes grease, moreover, it is not obvious.
bzoz commentedon Jun 23, 2016
There is more discussion about this real path issue here: #7175.
Loghorn commentedon Jul 8, 2016
My situation is even worse, if possible. I'm using Visual Studio Code to develop and debug node projects.
I frequently switch project, so to simplify my workflow I use
substto make the root of the project act like a disk drive: this makes path shorter (with the side effect of reducing the Windows long path problem) and allows me to quickly change project simply by typing the drive letter.I recently upgraded to node v6.3.0 and I can't set breakpoint in VS Code anymore, because the modules are loaded with their 'real' path instead of the
substituted one.--preserve-symlinksdoesn't resolve the situation: the main file loading ignores the flag and because all subsequentrequireuse a relative path all the files are loaded with the real path, making impossible setting breakpoints (that needs the absolute path of the file)fs: restore JS implementation of realpath
fs: restore JS implementation of realpath