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
TypeError: Path must be a string. Received undefined #181
out as patch v1.9.1? I ran the tests, they are all passing.
Without this it's not currently possible to use resolve for non-real paths, which I need for a testing environment with an in-memory (virtual) file system. Sorry, that's actually possible by enabling preserveSymlinks, however that's not the desired solution for me in my case.
I run path.resolve for a directory that doesn't exist
fs.realpath(absoluteStart, ... has an error
the error is realPathErr.code = "ENOENT", so the callback doesn't get called
realStart is undefined
init(realStart) is called (because of ENOENT)
res = path.resolve(basedir, x); is called in line 58
TypeError: Path must be a string. Received undefined (because basedir is realStart which is undefined)
Expected behavior: if it's not a real path, pass the original absoluteStart instead of realStart, i. e. init(realPathErr ? absoluteStart : realStart), and still resolve.
@simonhaenisch i'm super on board with releasing a v1.9.1 that fixes this for you; is there any chance you could make a PR into v1.9.0 (not master) with a failing test case?
# non-existent basedir should not throw when preserveSymlinks is false
path.js:28
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.resolve (path.js:1168:7)
at init (~/resolve/lib/async.js:58:24)
at ~/resolve/lib/async.js:49:18
at gotStat (fs.js:1783:21)
at FSReqWrap.oncomplete (fs.js:152:21)
After:
# non-existent basedir should not throw when preserveSymlinks is false
ok 1 should be equal
ok 2 should be equal
1..2
# tests 2
# pass 2
# ok
(ran with Node v8.15.0 on macOS)
My branch is based of v1.9.0, but I'm not sure how to open a PR against that because it seems I can only open one against a branch but not a tag. Maybe you'll have to git checkout -b v1.9.0-patch v1.9.0 first and push it, so I can open the PR?
I don't have a Windows instance to run the tests on btw.
Activity
simonhaenisch commentedon Jan 12, 2019
@ljharb could we get this
v1.9.0...simonhaenisch:fix-path-must-be-string
out as patch
v1.9.1? I ran the tests, they are all passing.Without this it's not currently possible to useSorry, that's actually possible by enablingresolvefor non-real paths, which I need for a testing environment with an in-memory (virtual) file system.preserveSymlinks, however that's not the desired solution for me in my case.ljharb commentedon Jan 13, 2019
@simonhaenisch it's already in v1.9.0 - see 765b3cb
simonhaenisch commentedon Jan 13, 2019
It's not in the
v1.9.0tag that was released to npm... seehttps://github.com/browserify/resolve/blob/v1.9.0/lib/async.js#L49
ljharb commentedon Jan 13, 2019
The
realpathfix is; the "throw on invalid directory" breaking change is not (and won't be).simonhaenisch commentedon Jan 13, 2019
So the problem is:
preserveSysmlinks: truepath.resolvefor a directory that doesn't existfs.realpath(absoluteStart, ...has an errorrealPathErr.code = "ENOENT", so the callback doesn't get calledrealStartisundefinedinit(realStart)is called (because ofENOENT)res = path.resolve(basedir, x);is called in line 58TypeError: Path must be a string. Received undefined(becausebasedirisrealStartwhich isundefined)Expected behavior: if it's not a real path, pass the original
absoluteStartinstead ofrealStart, i. e.init(realPathErr ? absoluteStart : realStart), and still resolve.Does that clarify it?
ljharb commentedon Jan 13, 2019
@simonhaenisch i'm super on board with releasing a v1.9.1 that fixes this for you; is there any chance you could make a PR into v1.9.0 (not master) with a failing test case?
simonhaenisch commentedon Jan 13, 2019
Please see v1.9.0...simonhaenisch:fix-path-must-be-string, here is the test results without and with the fix.
Before:
After:
(ran with Node v8.15.0 on macOS)
My branch is based of
v1.9.0, but I'm not sure how to open a PR against that because it seems I can only open one against a branch but not a tag. Maybe you'll have togit checkout -b v1.9.0-patch v1.9.0first and push it, so I can open the PR?I don't have a Windows instance to run the tests on btw.
simonhaenisch commentedon Jan 16, 2019
@ljharb could you please create a branch based of the
v1.9.0tag and push it to remote, so I can open the PR?ljharb commentedon Jan 17, 2019
@simonhaenisch sorry for the delay; done! https://github.com/browserify/resolve/tree/1.9.0-next
simonhaenisch commentedon Jan 17, 2019
Thanks! PR is open (:
ljharb commentedon Jan 21, 2019
Merged into the next v1 release (will be v1.10.0); not yet merged into master. When it is, this will close.
v1.10.0
ljharb commentedon Jan 21, 2019
v1.10.0 is released; merged into master with ea7d38d