realpath works different on linux and windows.
For '..../somedir being a real path to a directory
on linux realpath(".../somedir/") =="..../somedir",
on windows realpath(".../somedir/") =="..../somedir/"
realpath should be useful for making paths more consistent in their behavior, not less.
The linux behavour matches that of the realpath command,
the windows behavior is what I would have expected to happen (but that is just me)
I guess this is a LibUV bug, maybe someone can test and upstream it?
One of the reasons to call realpath is to get a "canonical name" for a file, so it's not desirable for the result to depend on input details like whether there was or was not a trailing slash given in the input name. For files a trailing slash should probably lead to failure, for directories, we should either always return a result with or without a trailing slash, regardless of what the input had. It's kind of nice that a file and a directory with the same path have different canonical names, so maybe that's the better behavior. On the other hand, maybe it's weird for the canonical name for a directory to end in a slash.
Note that realpath has changed recently on Windows (#30611), and the new implementation should not have this problem I'm guessing. Are trailing slashes still an issue on master?
Most helpful comment
One of the reasons to call
realpathis to get a "canonical name" for a file, so it's not desirable for the result to depend on input details like whether there was or was not a trailing slash given in the input name. For files a trailing slash should probably lead to failure, for directories, we should either always return a result with or without a trailing slash, regardless of what the input had. It's kind of nice that a file and a directory with the same path have different canonical names, so maybe that's the better behavior. On the other hand, maybe it's weird for the canonical name for a directory to end in a slash.