-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Shebang is not valid for project dir and npm pack #7779
Comments
PS also it is not possible to work with nested dirs containing shebang:
'#' is valid name for dir. If you have a special list of invalid symbols for dir names please publish it. Thank you. |
I've found that
It looks like |
Ok, so we can see that Well, I need a reliable way to detect what is valid alphabet for path and path component. Let's do it:
Result:
The complete workaround looks as follows:
I hope it will help to workaround this issue. |
Hey @andrew-aladjev 👋
|
I've tested and it fails.
Please reopen this issue. Maybe you didn't catch it. I mean shebang is not valid for project dir. Project dir is a storage dir for your current project, not some folder inside project. |
Ah I see whats happening now, the This code shouldn't be parsing paths as urls. |
I believe we support file paths as url to abide by a web standards that fit better with the inner workings of couch or s3 to consistently store and retrieve packages. The "file" URI Scheme specification defined in RFC 8089 doesn't list out all characters not allowed in the path https://datatracker.ietf.org/doc/html/rfc8089#appendix-B
You can check if a path is valid with a simple function like this: const checkPath = path => new URL('file:', `file://${path}`).pathname === path I'd be open to having a better error message here as opposed to jumping up one directory looking for a package.json and ignoring the invalid directory name with the |
The URL spec doesn't have any bearing on file paths, though - file paths are their own (better) thing, and npm works with files. |
Hello everyone. Honestly speaking, File system section in RFC 8089 is related to remote file systems, for example: I think, it is especially true for situation we have today: NPM should not use |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
It doesn't matter how long dir name will be, if it contains shebang than
npm pack
tries to readpackage.json
from parent dir.Expected Behavior
All printable ascii symbols expect
/
should be valid for project dir.Steps To Reproduce
No response
Environment
The text was updated successfully, but these errors were encountered: