-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix #4628: npm install to a wrong location #6742
Fix #4628: npm install to a wrong location #6742
Conversation
We require contributors to sign our Contributor License Agreement, and we don't have @geeee on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
Nice find. Two notes:
If so, |
Thanks for lookin into it!
Considering that running
Isn't this what 'languages' folder is for? Or are you talking about something like root npm package with single node_modules folder used for all languages? If so then this sounds like a design decision that is beyond my competence in this project, obviously. Right now the overlap of packages used in different languages is quite small, so I'm not sure if potential gains are worth it.
I'm not sure if it's going to change anything. But if so, it might be a good idea to put this prefix into global_npmrc file and use that file instead of blank_global_npmrc. |
re: relative path My main idea was to use a more explicit path form to see it in the node logs somewhere, if only the node command fails: otherwise, the real abs path is only used in the Rust code and until adding more logging there we cannot be sure We do indeed install various languages' packages separately, sorry for the confusion, so I guess my cache-related question is not really valid, please disregard it. I would merge it but let's ask @ForLoveOfCats to have a peek at it before, just in case (my frontend infra knowledge is bad). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, we were theorizing that something was causing NPM to install files into the wrong directory and our theory was that it had something to do with the global user config, hence that override, but this makes so much more sense!
I think the relative path is fine, an absolute path would definitely be a bit better but I don't think it matters that much as this patch stands.
I'm much more interested in if we can move this argument into the run_npm_subcommand method so all codepaths interacting with NPM are sure to use the correct path. That would need to use an absolute path, ie the directory argument if present, omitting the argument otherwise.
Thanks so much for figuring this out, we've been scratching our heads over this for quite a while!
0ceb4bf
to
42e605a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🚢
By default
npm install
will walk up the folder tree checking for a folder that contains either a package.json file, or a node_modules folder. If such a thing is found, then that is treated as the effective "current directory" for the purpose of running npm commands.This caused npm dependencies for language servers sometimes to be installed in the wrong folder, described in #4628.
Adding
--prefix ./
tonpm install
forces node_runtime.npm_install_packages to install packages in provided path even if node_modules dir exists somewhere up the filesystem tree from installation path.Release Notes: