Sentry-cli: Not able to install without bash, and not able to uninstall with bash

Created on 11 Nov 2019  路  4Comments  路  Source: getsentry/sentry-cli

It looks like there is no way to run sentry-cli in a clean way, not install, or installed but not able to uninstall.

System: Ubuntu 18.04.3 LTS
Node: 12.10.0

To reproduce this, start a clean environment with docker and run commands below to test.

docker run --rm -it node:lts /bin/bash

or

docker run --rm it node:lts-buster /bin/bash

Problem 1:
Install with npm, root don't have permission to /root?

root@8b8fe383db83:~# npm i -g @sentry/cli
/usr/bin/sentry-cli -> /usr/lib/node_modules/@sentry/cli/bin/sentry-cli

> @sentry/[email protected] install /usr/lib/node_modules/@sentry/cli
> node scripts/install.js

Error: EACCES: permission denied, mkdir '/root/.npm/sentry-cli'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @sentry/[email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @sentry/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-11T06_42_00_118Z-debug.log
root@8b8fe383db83:~# 

Problem 2:
Run with npx

root@8b8fe383db83:~# npx @sentry/cli sentry-cli
internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module '/root/.npm/_npx/10940/lib/node_modules/@sentry/cli/scripts/install.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @sentry/[email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @sentry/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-11T06_44_07_173Z-debug.log
Install for [ '@sentry/cli@latest' ] failed with code 1
root@8b8fe383db83:~# 

Problem 3:
Uninstall sentry which installed with bash script

root@8b8fe383db83:~# sentry-cli uninstall
  INFO    2019-11-11 06:52:49.363803311 +00:00 Loaded config from /root/.sentryclirc
  DEBUG   2019-11-11 06:52:49.363829051 +00:00 sentry-cli version: 1.49.0, platform: "linux", architecture: "x86_64"
  INFO    2019-11-11 06:52:49.363839390 +00:00 sentry-cli was invoked with the following command line: "sentry-cli" "uninstall"
Do you really want to uninstall sentry-cli? [y/n] y
Need to sudo to uninstall /usr/local/bin/sentry-cli
  DEBUG   2019-11-11 06:52:51.827868498 +00:00 error: running update nagger
  INFO    2019-11-11 06:52:51.827986347 +00:00 Skipping update nagger update check
error: No such file or directory (os error 2)
  DEBUG   2019-11-11 06:52:51.828440711 +00:00 client close; no transport to shut down  (from sentry)
root@8b8fe383db83:~# 

# Loop, never uninstall

Most helpful comment

Problem 1:

Looks like npm doesn't allow to install globally for root by default, but it can be changed if you do

npm config set unsafe-perm true

There's some additional information in this comment/thread: https://github.com/nvm-sh/nvm/issues/1407#issuecomment-316858947

Problem 2:

Hm, is it the full log, or there's something else in /root/.npm/_logs/2019-11-11T06_44_07_173Z-debug.log? I don't think we've ever tested sentry-cli with npx yet, though.

Problem 3:

Can confirm, it doesn't work as expected. We'll have a look.

Thanks for the report!

All 4 comments

Problem 1:

Looks like npm doesn't allow to install globally for root by default, but it can be changed if you do

npm config set unsafe-perm true

There's some additional information in this comment/thread: https://github.com/nvm-sh/nvm/issues/1407#issuecomment-316858947

Problem 2:

Hm, is it the full log, or there's something else in /root/.npm/_logs/2019-11-11T06_44_07_173Z-debug.log? I don't think we've ever tested sentry-cli with npx yet, though.

Problem 3:

Can confirm, it doesn't work as expected. We'll have a look.

Thanks for the report!

It looks like npm config set unsafe-perm true also fixes Problem 2.

@tonyo Confirm work.

Problem 1: Solved above
Problem 2: It works fine now. You don't need to specify the name of a binary, just a package, so npx @sentry/cli <commands>
Problem 3: https://github.com/getsentry/sentry-cli/pull/652

Was this page helpful?
0 / 5 - 0 ratings