-
Notifications
You must be signed in to change notification settings - Fork 592
[node] - Install pnpm as non-root user to prevent root-owned npm cache #1625
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -386,13 +386,7 @@ if [ ! -z "${PNPM_VERSION}" ] && [ "${PNPM_VERSION}" = "none" ]; then | |
| echo "Ignoring installation of PNPM" | ||
| else | ||
| if bash -c ". '${NVM_DIR}/nvm.sh' && type npm >/dev/null 2>&1"; then | ||
| ( | ||
| . "${NVM_DIR}/nvm.sh" | ||
| [ ! -z "$http_proxy" ] && npm set proxy="$http_proxy" | ||
| [ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy" | ||
| [ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy" | ||
| npm install -g pnpm@$PNPM_VERSION --force | ||
| ) | ||
| su ${USERNAME} -c "umask 0002 && . '${NVM_DIR}/nvm.sh' && npm install -g pnpm@${PNPM_VERSION} --force" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any implications for switching to user-based vs root based? There may have been assumptions made by others based on this being root-based. If it could cause issues, we may want to consider adding an option and defaulting to the original approach.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every other install block installs things as the user Further, this doesn't just cause pnpm-specific things to be owned by root, it can impact other common Node directories if this block runs first. From my commit message:
The unconditional ownership of some files by root is the essence of the bug. Features are (I believe) supposed to respect the active user (and every other part of this script does). A flag would be a "would you like to to fix the bug" option. Users can continue to set |
||
| else | ||
| echo "Skip installing pnpm because npm is missing" | ||
| fi | ||
|
|
||
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.
Others may need these proxies; could they be added back?
Uh oh!
There was an error while loading. Please reload this page.
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.
From my commit message:
So, this doesn't change anything for users. They can still set
$http_proxyand npm will directly respect it.Every other install block works this way. The removed code just seems like leftovers of a workaround. If the workaround is actually necessary for some reason, than it's a bug that every other install block lacks it.