Skip to content

Commit 876304f

Browse files
authored
Remove --unsafe-perm flag from install scripts (#7953)
npm 12 rejects unknown CLI flags, so the npm install path crashes with EUNKNOWNCONFIG before installing. The flag has been a no-op since npm 7; remove it from install.sh and the postinstall guard.
1 parent c22dc74 commit 876304f

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

ci/build/npm-postinstall.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ main() {
7676
exit 1
7777
fi
7878

79-
# Under npm, if we are running as root, we need --unsafe-perm otherwise
80-
# post-install scripts will not have sufficient permissions to do their thing.
81-
if is_root; then
82-
case "${npm_config_user_agent-}" in npm*)
83-
if [ "${npm_config_unsafe_perm-}" != "true" ]; then
84-
echo "Please pass --unsafe-perm to npm to install code-server"
85-
echo "Otherwise post-install scripts will not have permissions to run"
86-
echo "See https://docs.npmjs.com/misc/config#unsafe-perm"
87-
echo "See https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm"
88-
exit 1
89-
fi
90-
;;
91-
esac
92-
fi
9379

9480
if ! vscode_install; then
9581
echo "You may not have the required dependencies to build the native modules."
@@ -110,7 +96,7 @@ install_with_yarn_or_npm() {
11096
# end-user we want to keep using whatever package manager is in use.
11197
case "${npm_config_user_agent-}" in
11298
npm*)
113-
if ! npm install --unsafe-perm --omit=dev; then
99+
if ! npm install --omit=dev; then
114100
return 1
115101
fi
116102
;;

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ install_npm() {
436436
fi
437437
echoh "Installing with npm."
438438
echoh
439-
"$sh_c" "$NPM_PATH" install -g "code-server@$VERSION" --unsafe-perm
439+
"$sh_c" "$NPM_PATH" install -g "code-server@$VERSION"
440440
NPM_BIN_DIR="\$($NPM_PATH bin -g)" echo_npm_postinstall
441441
return
442442
fi

0 commit comments

Comments
 (0)