Skip to content
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] npm install truncates paths at # #6809

Closed
2 tasks done
hseg opened this issue Sep 15, 2023 · 4 comments
Closed
2 tasks done

[BUG] npm install truncates paths at # #6809

hseg opened this issue Sep 15, 2023 · 4 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x

Comments

@hseg
Copy link

hseg commented Sep 15, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm install appears to truncate its arguments after the first # character, thus not finding the correct file when the path contains a #.

Expected Behavior

The only characters that should cause trouble in unix systems in paths are control characters (in particular, NUL) and forward/backward slashes (as path components). Under windows, further restrictions on valid paths exist, but they shouldn't prevent npm from finding files on valid paths.

Steps To Reproduce

Encountered while building the package https://aur.archlinux.org/packages/nodejs-nativefier in /home/gesh/aur/9#deps/whatsapp-nativifier/nodejs-nativefier, problem vanished when building in /home/gesh/aur/whatsapp-nativifier/nodejs-nativefier.
Log attached

Context-agnostic instructions:

  • Download eg http://registry.npmjs.org/nativefier/-/nativefier-52.0.0.tgz to ~/0#broken/
  • npm install ~/0#broken/*.tgz
  • npm complains it can't find ~/0
  • However, mv ~/0#broken ~/fixed
  • npm install ~/fixed/*.tgz
  • Everything works fine

Environment

; "user" config from /home/gesh/.local/etc/npm/npmrc

cache = "/home/gesh/.local/var/cache/npm" 
init-module = "/home/gesh/.local/etc/npm/config/npm-init.js" 
prefix = "/home/gesh/.local" 

; "env" config from environment

userconfig = "/home/gesh/.local/etc/npm/npmrc" 

; node bin location = /usr/bin/node
; node version = v20.6.1
; npm local prefix = /home/gesh
; npm version = 10.1.0
; cwd = /home/gesh
; HOME = /home/gesh
; Run `npm config ls -l` to show all defaults.
@hseg hseg added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Sep 15, 2023
@lukekarrys lukekarrys added Release 9.x work is associated with a specific npm 9 release and removed Needs Triage needs review for next steps labels Oct 6, 2023
@lukekarrys
Copy link
Contributor

The # does not cause problems in paths but npm does use it to determine a commit-ish for a dependency, which might be what is happening here. But it should be possible to first determine if it is a valid path and then use the full path.

@lukekarrys lukekarrys added the Priority 2 secondary priority issue label Oct 6, 2023
@ljharb
Copy link
Contributor

ljharb commented Oct 7, 2023

Seems like it’s assuming it’s a github slug. Using ~ isn’t reliable, what happens if you use $HOME? That way npm will know it’s a path since it’ll start with /

@hseg
Copy link
Author

hseg commented Oct 9, 2023

Correction, broken invocation was (from package management system)

npm install -g --cache /home/gesh/aur/9#deps/whatsapp-nativifier/nodejs-nativefier/src/npm-cache --prefix /home/gesh/aur/9#deps/whatsapp-nativifier/nodejs-nativefier/pkg/nodejs-nativefier/usr /home/gesh/aur/9#deps/whatsapp-nativifier/nodejs-nativefier/src/nodejs-nativefier-52.0.0.tgz

In particular, note all paths are absolute

@milaninfy
Copy link
Contributor

This is fixed by #8115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x
Projects
None yet
Development

No branches or pull requests

4 participants