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

Can't NPM install new CLI without using sudo #2480

Closed
pgonzaleznetwork opened this issue Sep 20, 2023 · 4 comments
Closed

Can't NPM install new CLI without using sudo #2480

pgonzaleznetwork opened this issue Sep 20, 2023 · 4 comments

Comments

@pgonzaleznetwork
Copy link

Note
Before you submit your issue, make sure that:

  • You're using the latest version of Salesforce CLI.
  • You've searched both open and closed issues for related posts.
  • You've used the doctor command to diagnose common issues.
  • You understand that GitHub Issues don't adhere to any agreement or SLA.
    • If you require immediate assistance, use official channels such as Salesforce Customer Support.

Summary

This is a follow up of #2478. When I try to install the new sfv2 cli with NPM, I get an access error. Using sudo fixes the error, but then I need to use sudo every time I run a command.

Steps To Reproduce

IMPORTANT
Provide a repository that's configured to reproduce the issue. If you are unable to provide a repo, please explain why not. The more info we have from the start, the faster we can resolve your issue.
We may close your issue if you don't include proper instructions.

  • Generate a project with sf project generate or fork dreamhouse-lwc.
  • Provide detailed step-by-step instructions on how to reproduce the issue.

I made sure to uninstall the whole CLI using these instructions.

Then, I ran

npm install @salesforce/cli --global

And got the following

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/@salesforce/cli
npm ERR! dest /usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/@salesforce/cli' -> '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/@salesforce/cli' -> '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/lib/node_modules/@salesforce/cli',
npm ERR!   dest: '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pgonzalez/.npm/_logs/2023-09-20T15_24_15_875Z-debug-0.log

I ran cat on /Users/pgonzalez/.npm/_logs/2023-09-20T15_24_15_875Z-debug-0.log and got the following

0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/Users/pgonzalez/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:setEnvs Completed in 1ms
15 timing config:load Completed in 5ms
16 timing npm:load:configload Completed in 5ms
17 timing npm:load:mkdirpcache Completed in 0ms
18 timing npm:load:mkdirplogs Completed in 0ms
19 verbose title npm install @salesforce/cli
20 verbose argv "install" "@salesforce/cli" "--global"
21 timing npm:load:setTitle Completed in 5ms
22 timing config:load:flatten Completed in 2ms
23 timing npm:load:display Completed in 2ms
24 verbose logfile logs-max:10 dir:/Users/pgonzalez/.npm/_logs/2023-09-20T15_24_15_875Z-
25 verbose logfile /Users/pgonzalez/.npm/_logs/2023-09-20T15_24_15_875Z-debug-0.log
26 timing npm:load:logFile Completed in 3ms
27 timing npm:load:timers Completed in 0ms
28 timing npm:load:configScope Completed in 0ms
29 timing npm:load Completed in 16ms
30 timing config:load:flatten Completed in 0ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 1 files
33 timing idealTree:init Completed in 3ms
34 timing idealTree:userRequests Completed in 2ms
35 silly idealTree buildDeps
36 silly fetch manifest @salesforce/cli@*
37 silly logfile done cleaning log files
38 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fcli 1231ms (cache revalidated)
39 silly placeDep ROOT @salesforce/[email protected] OK for:  want: *
40 silly fetch manifest @oclif/[email protected]
41 silly fetch manifest @oclif/[email protected]
42 silly fetch manifest @oclif/[email protected]
43 silly fetch manifest @oclif/[email protected]
44 silly fetch manifest @oclif/[email protected]
45 silly fetch manifest @oclif/[email protected]
46 silly fetch manifest @oclif/[email protected]
47 silly fetch manifest @oclif/[email protected]
48 silly fetch manifest @oclif/[email protected]
49 silly fetch manifest @oclif/[email protected]
50 silly fetch manifest @oclif/[email protected]
51 silly fetch manifest @salesforce/core@^5.2.0
52 silly fetch manifest @salesforce/[email protected]
53 silly fetch manifest @salesforce/[email protected]
54 silly fetch manifest @salesforce/[email protected]
55 silly fetch manifest @salesforce/[email protected]
56 silly fetch manifest @salesforce/[email protected]
57 silly fetch manifest @salesforce/[email protected]
58 silly fetch manifest @salesforce/[email protected]
59 silly fetch manifest @salesforce/[email protected]
60 silly fetch manifest @salesforce/[email protected]
61 silly fetch manifest @salesforce/[email protected]
62 silly fetch manifest @salesforce/[email protected]
63 silly fetch manifest @salesforce/[email protected]
64 silly fetch manifest @salesforce/[email protected]
65 silly fetch manifest @salesforce/[email protected]
66 silly fetch manifest @salesforce/[email protected]
67 silly fetch manifest @salesforce/[email protected]
68 silly fetch manifest @salesforce/[email protected]
69 silly fetch manifest @salesforce/[email protected]
70 silly fetch manifest debug@^4.3.4
71 silly fetch manifest tslib@^2.4.1
72 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-autocomplete 129ms (cache revalidated)
73 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fcore 232ms (cache revalidated)
74 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-version 251ms (cache revalidated)
75 http fetch GET 200 https://registry.npmjs.org/@oclif%2fcore 258ms (cache revalidated)
76 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-which 257ms (cache revalidated)
77 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-commands 261ms (cache revalidated)
78 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-not-found 261ms (cache revalidated)
79 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-search 261ms (cache revalidated)
80 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-help 264ms (cache revalidated)
81 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-data 264ms (cache revalidated)
82 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-limits 274ms (cache revalidated)
83 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-warn-if-update-available 278ms (cache revalidated)
84 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-schema 290ms (cache revalidated)
85 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-org 308ms (cache revalidated)
86 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-info 318ms (cache revalidated)
87 http fetch GET 200 https://registry.npmjs.org/debug 321ms (cache revalidated)
88 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-auth 342ms (cache revalidated)
89 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-templates 339ms (cache revalidated)
90 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-update 349ms (cache revalidated)
91 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-source 347ms (cache revalidated)
92 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-marketplace 354ms (cache revalidated)
93 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-settings 355ms (cache revalidated)
94 http fetch GET 200 https://registry.npmjs.org/tslib 353ms (cache revalidated)
95 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-telemetry 360ms (cache revalidated)
96 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-trust 396ms (cache revalidated)
97 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-sobject 400ms (cache revalidated)
98 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-user 400ms (cache revalidated)
99 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-login 449ms (cache revalidated)
100 http fetch GET 200 https://registry.npmjs.org/@oclif%2fplugin-plugins 743ms (cache revalidated)
101 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-deploy-retrieve 1147ms (cache revalidated)
102 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fsf-plugins-core 1243ms (cache revalidated)
103 http fetch GET 200 https://registry.npmjs.org/@salesforce%2fplugin-apex 1770ms (cache revalidated)
104 timing idealTree:#root Completed in 3057ms
105 timing idealTree:buildDeps Completed in 3057ms
106 timing idealTree:fixDepFlags Completed in 0ms
107 timing idealTree Completed in 3064ms
108 timing reify:loadTrees Completed in 3382ms
109 timing reify:diffTrees Completed in 3ms
110 silly reify mark retired [
110 silly reify   '/usr/local/lib/node_modules/@salesforce/cli',
110 silly reify   '/usr/local/bin/sf',
110 silly reify   '/usr/local/bin/sfdx'
110 silly reify ]
111 silly reify moves {
111 silly reify   '/usr/local/lib/node_modules/@salesforce/cli': '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY',
111 silly reify   '/usr/local/bin/sf': '/usr/local/bin/.sf-KL5k5Det',
111 silly reify   '/usr/local/bin/sfdx': '/usr/local/bin/.sfdx-ddgNS6JY'
111 silly reify }
112 timing reify:rollback:retireShallow Completed in 0ms
113 timing command:install Completed in 3390ms
114 verbose stack Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/@salesforce/cli' -> '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'
115 verbose cwd /Users/pgonzalez
116 verbose Darwin 21.0.1
117 verbose node v16.13.0
118 verbose npm  v9.6.2
119 error code EACCES
120 error syscall rename
121 error path /usr/local/lib/node_modules/@salesforce/cli
122 error dest /usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY
123 error errno -13
124 error [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/@salesforce/cli' -> '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'] {
124 error   errno: -13,
124 error   code: 'EACCES',
124 error   syscall: 'rename',
124 error   path: '/usr/local/lib/node_modules/@salesforce/cli',
124 error   dest: '/usr/local/lib/node_modules/@salesforce/.cli-w0hFn0bY'
124 error }
125 error
125 error The operation was rejected by your operating system.
125 error It is likely you do not have the permissions to access this file as the current user
125 error
125 error If you believe this might be a permissions issue, please double-check the
125 error permissions of the file and its containing directories, or try running
125 error the command again as root/Administrator.
126 verbose exit -13
127 timing npm Completed in 3415ms
128 verbose unfinished npm timer reify 1695223455900
129 verbose unfinished npm timer reify:retireShallow 1695223459288
130 verbose code -13
131 error A complete log of this run can be found in:
131 error     /Users/pgonzalez/.npm/_logs/2023-09-20T15_24_15_875Z-debug-0.log

Expected result

I should be able to install the CLI without sudo

Actual result

Already described

System Information

I'm using bash. There's no version of the CLI, because I'm unable to install it :)

nothing to add

Additional information

@pgonzaleznetwork pgonzaleznetwork added the investigating We're actively investigating this issue label Sep 20, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@github-actions
Copy link

Hello @pgonzaleznetwork 👋 It looks like you didn't include the full Salesforce CLI version information in your issue.
Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

  • Make sure you've provided detailed steps to reproduce your issue.
    • A repository that clearly demonstrates the bug is ideal.
  • Make sure you've installed the latest version of Salesforce CLI. (docs)
    • Better yet, try the rc or nightly versions. (docs)
  • Try running the doctor command to diagnose common issues.
  • Search GitHub for existing related issues.

Thank you!

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Sep 20, 2023
@pgonzaleznetwork
Copy link
Author

@mshanemc notice there's no more info required as I can't provide that info :)

@mshanemc
Copy link
Contributor

mshanemc commented Sep 20, 2023

You can ls -ld the various levels of where the error is happening /usr/local/lib/node_modules/@salesforce/cli

You want /usr/local/lib to be accessible as you, not only as root. See the man for the chown command for how to change the ownership of the folder.

There's also another approach to this (keep global modules in a different folder you own) https://github.com/sindresorhus/guides/blob/main/npm-global-without-sudo.md if you can't/don't want to change perms on the standard location

@mshanemc mshanemc removed the more information required Issue requires more information or a response from the customer label Sep 20, 2023
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

No branches or pull requests

3 participants