-
Notifications
You must be signed in to change notification settings - Fork 173
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
corepack disable incorrectly deletes original package manager #112
Comments
Just ran into this issue too trying to make sure Corepack didn't alter the configuration on my system. Simple test case:
Enabling and disabling Corepack should return the system to the original state. |
It seems difficult to do in a way that won't result in other edge cases. For that to work, we'd need to store the links somewhere, so we can restore them. When using nvm or similar tools, this "where" isn't obvious. Generally, I feel like it's not a huge deal if |
I created this issue before It was really unexpected to have
Perhaps keep a backup copy like the following pseudocode:
|
In general, when trying out a new tool, I try not to use tools that will completely destroy my existing setup. I'm not choosing to use While it may be the case that once I have everything working, I would use I've already been struggling with the docs that state that
And I now have this as a way to find out if it's enabled or disabled, since
The last thing I'm trying to figure out is how to ensure it doesn't kill one of our developers configuration just because they decide to disable it after switching to a different project. Bottom line: it's a trust issue. If I can't trust that an operation can be reversed, I'm much less likely to want to use that operation in the first place. |
Also, one of the reasons I looked into this is that the script in question had this line:
Whoever wrote the script either didn't understand the consequences of One of our developers ran this script and then had to figure out why all her other projects were running the wrong version of Part of what I'm doing in learning the issues around using |
For those who want a safe way to enable/disable corepack, I wrote this bash script. With this script, This isn't guaranteed to work in all environments, but in theory it should. I tested it with Additional commands include:
All other commands are passed through to
|
Instead of backing up existing bins/symlinks, how about this? mkdir -p "$HOME/.corepack/bin"
echo "export PATH=$HOME/.corepack/bin:\$PATH" >> ~/.zshrc
# create corepack shims in my `.corepack` dir, so no system bins will be overridden
corepack enable --install-directory ~/.corepack/bin
# removing the shims now just reveals the previous binaries again
corepack disable --install-directory ~/.corepack/bin |
I'm not sure if this is correct way, but it worked when recovering from $ corepack disable npm
$ npm -v
zsh: command not found: npm
# recovery
$ corepack enable npm # shims : $NVM_BIN/npm -> ../lib/node_modules/corepack/dist/npm.js
$ npm i -g npm # shims : $NVM_BIN/npm -> ../lib/node_modules/npm/bin/npm-cli.js Also, |
I call |
Running with Node.js v16.15.0 on macOS
I would expected
corepack disable pnpm
to revert to the previous global install of 7.1.6The text was updated successfully, but these errors were encountered: