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

Ensure prefix subdirectories are created when installing #858

Merged
merged 1 commit into from
Oct 22, 2020

Conversation

charlespierce
Copy link
Contributor

Closes #857

Info

  • There is an upstream bug in npm@7 where global installs into a custom prefix will fail if the expected lib subdirectory doesn't already exist ([BUG] npm does not create --prefix dir npm/cli#2012)
  • While this will likely get fixed, we can also work around it internally in Volta by ensuring the expected lib and bin directories are created before running an install.

Changes

  • Updated the creation of the staging directory to ensure that the appropriate lib and bin directories are also created.

Tested

  • Confirmed that installing packages under npm 7 works as expected.

@dherman dherman self-requested a review October 22, 2020 17:29
Copy link
Collaborator

@dherman dherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

Copy link
Contributor

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up so quickly!

@charlespierce charlespierce merged commit 6bd7418 into volta-cli:main Oct 22, 2020
@charlespierce charlespierce deleted the package_install_subdirs branch October 22, 2020 17:30
@DirtyF
Copy link

DirtyF commented Oct 22, 2020

It still fails with some packages like gatbsy-cli:

➜ volta -v
0.9.1

➜ volta list --format=plain
package @11ty/eleventy@0.11.0 / eleventy / node@12.19.0 npm@built-in (default)
package gatsby-cli@2.12.111 / gatsby / node@12.19.0 npm@built-in (default)
package lerna@3.22.1 / lerna / node@12.19.0 npm@built-in (default)
package netlify-cli@2.65.7 / ntl, netlify / node@12.19.0 npm@built-in (default)
package tailwindcss@1.9.5 / tailwind, tailwindcss / node@12.19.0 npm@built-in (default)

➜ volta install lerna
success: installed lerna@3.22.1 with executables: lerna

➜ volta install vuepress
success: installed vuepress@1.7.1 with executables: vuepress

➜ volta install gatsby-cli
error: Could not install package 'gatsby-cli'

Please confirm the package is valid and run with `--verbose` for more diagnostics.

~ took 16s
➜ volta uninstall gatsby-cli
Removed executable 'gatsby' installed by 'gatsby-cli'
success: package 'gatsby-cli' uninstalled

~ took 6s
➜ volta install gatsby-cli
error: Could not install package 'gatsby-cli'

Please confirm the package is valid and run with `--verbose` for more diagnostics.

@charlespierce
Copy link
Contributor Author

Hi @DirtyF, that looks like it may be a bug internally in npm@7 or in gatsby-cli: When I run npm i -g gatsby-cli I get:

$ npm i -g gatsby-cli
npm ERR! Cannot read property 'matches' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cpierce/.npm/_logs/2020-10-22T19_29_58_338Z-debug.log

Which is a JS type error, not something Volta can work around unfortunately. Confirmed that:

  • Installing gatsby-cli with npm@6 works as expected
  • Installing gatsby-cli with npm@7 while bypassing Volta's custom behavior also fails.

So my guess is it's a separate, unrelated bug within npm@7

@DirtyF
Copy link

DirtyF commented Oct 22, 2020

Right, it's easy to switch from npm@7 to npm@6 with Volta ⚡

volta install npm@6
success: installed and set npm@6.14.8 as default

volta install gatsby-cli@2
success: installed gatsby-cli@2.12.111 with executables: gatsby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't install packages with npm@7 and Volta 0.9
4 participants