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 run commands without sudo: "EACCES: permission denied" error #2791

Closed
jonathanmorris180 opened this issue Mar 23, 2024 · 8 comments
Closed
Labels
more information required Issue requires more information or a response from the customer

Comments

@jonathanmorris180
Copy link

jonathanmorris180 commented Mar 23, 2024

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

I recently updated my Salesforce CLI to the latest version. Now, whenever I run any commands, I'm getting errors like this:

$ sf --version                                                                                                                                                                                                                                                                                                                                                                           
@salesforce/cli/2.33.3 darwin-arm64 node-v20.11.1
node:events:496
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/Users/jonathanmorris/.sf/sf-2024-03-23.log'
Emitted 'error' event on ThreadStream instance at:
    at Immediate.<anonymous> (/usr/local/lib/sf/node_modules/thread-stream/index.js:366:12)
    at process.processImmediate (node:internal/timers:478:21)

Node.js v20.11.1

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.
  • Install the latest version of the Salesforce CLI on:
ProductName:            macOS
ProductVersion:         14.4
BuildVersion:           23E214
  • Run any command (e.g. sf org list --json)

Expected result

It outputs the expected orgs as json

Actual result

You get the error above

System Information

Using shell zsh
System information:

ProductName:            macOS
ProductVersion:         14.4
BuildVersion:           23E214
$ sf version --verbose --json                                                                                                                                                                                                                                                                                                                                                            
node:events:496
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/Users/jonathanmorris/.sf/sf-2024-03-23.log'
Emitted 'error' event on ThreadStream instance at:
    at Immediate.<anonymous> (/usr/local/lib/sf/node_modules/thread-stream/index.js:366:12)
    at process.processImmediate (node:internal/timers:478:21)

Node.js v20.11.1

Additional information

  • I have checked the permissions of my ~/.sf directory and I have all needed permissions:
$ ls -la | grep -E "(\.sf)$"                                                                                                                                                                                                                                                                                                                                                        
drwx------   18 jonathanmorris  staff         576 Mar 22 21:00 .sf
{"level":40,"time":1711155668955,"name":"sf:TelemetryReporter","msg":"Connection to https://dc.services.visualstudio.com timed out after 1000 ms"}
{"level":40,"time":1711164340372,"name":"sf:TelemetryReporter","msg":"Connection to https://dc.services.visualstudio.com timed out after 1000 ms"}

Update:
I downgraded to @salesforce/[email protected] with npm and it started working. Would love to know what the issue is with later versions.

@jonathanmorris180 jonathanmorris180 added the investigating We're actively investigating this issue label Mar 23, 2024
Copy link

Hello @jonathanmorris180 👋 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 Mar 23, 2024
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.

@cristiand391
Copy link
Member

For some reason, running with sudo makes commands work

@jonathanmorris180 did you npm install it with sudo too? see: #2480 (comment)

@jonathanmorris180
Copy link
Author

@cristiand391 I can try doing that for the latest release installed with npm, but why would that be needed for the binary installation from https://developer.salesforce.com/tools/salesforcecli?

Copy link

github-actions bot commented Apr 4, 2024

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

@github-actions github-actions bot added the stale label Apr 4, 2024
@jonathanmorris180
Copy link
Author

@cristiand391 Any further info on this? Would be great to get a resolution.

@cristiand391
Copy link
Member

cristiand391 commented Apr 4, 2024

@jonathanmorris180 sorry, I was out most of the last week.

can you check if you have a log file owned by the root user?

ls -la ~/.sf/*.log

I can repro the error when I change to owner of any log to root (chown root <filepath>):

➜  ~ ls -la | grep -E "(\.sf)$"
drwx------@   8 cdominguez  staff    256 Apr  4 12:33 .sf
➜  ~ ls -la ~/.sf/*.log
-rw-r--r--  1 root  staff  0 Apr  4 12:24 /Users/cdominguez/.sf/sf-2024-04-04.log
➜  ~ sf config list
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/Users/cdominguez/.sf/sf-2024-04-04.log'
Emitted 'error' event on ThreadStream instance at:
    at Immediate.<anonymous> (/Users/cdominguez/.nvm/versions/node/v20.10.0/lib/node_modules/@salesforce/cli/node_modules/thread-stream/index.js:366:12)
    at process.processImmediate (node:internal/timers:478:21)

Node.js v20.10.0

and then change the owner back to my username:

➜  ~ chown cdominguez ~/.sf/*.log
chown: /Users/cdominguez/.sf/sf-2024-04-04.log: Operation not permitted
➜  ~ sudo chown cdominguez ~/.sf/*.log
Password:
➜  ~ ls -la ~/.sf/*.log
-rw-r--r--  1 cdominguez  staff  0 Apr  4 12:24 /Users/cdominguez/.sf/sf-2024-04-04.log
➜  ~ sf config list
List Config
=====================================
| Name              Location    Value
| ───────────────── ─────────── ─────
| disable-telemetry Environment true
| target-dev-hub    Global      na40

@github-actions github-actions bot removed the stale label Apr 5, 2024
@jonathanmorris180
Copy link
Author

Hi @cristiand391, no worries, thanks for looking into it. All the log files and the .sf dir are owned by my user:

ls -la ~ | grep -E "(\.sf)$"  
drwx------   16 jonathanmorris  staff         512 Apr  4 20:00 .sf
ls -la ~/.sf/*.log     
-rw-r--r--  1 jonathanmorris  staff   588 Mar 29 12:02 /Users/jonathanmorris/.sf/sf-2024-03-29.log
-rw-r--r--  1 jonathanmorris  staff  3087 Apr  1 17:59 /Users/jonathanmorris/.sf/sf-2024-04-01.log
-rw-r--r--  1 jonathanmorris  staff   735 Apr  2 16:08 /Users/jonathanmorris/.sf/sf-2024-04-02.log
-rw-r--r--  1 jonathanmorris  staff  2352 Apr  3 19:23 /Users/jonathanmorris/.sf/sf-2024-04-03.log
-rw-r--r--  1 jonathanmorris  staff  1470 Apr  4 19:58 /Users/jonathanmorris/.sf/sf-2024-04-04.log
-rw-r--r--  1 jonathanmorris  staff  1176 Apr  4 20:34 /Users/jonathanmorris/.sf/sf-2024-04-05.log
-rw-r--r--  1 jonathanmorris  staff     0 Mar 23 20:15 /Users/jonathanmorris/.sf/sf.log

Weirdly, I just tried updating to the latest version again and now somehow it's working:

npm list -g                                                                                                                                                                                                                                                                                                                                                                            
/Users/jonathanmorris/.nvm/versions/node/v20.11.1/lib
├── @salesforce/[email protected]
├── [email protected]
└── [email protected]
npm install --global @salesforce/[email protected]                                                                                                                                                                                                                                                                                                                                            

added 229 packages, removed 162 packages, and changed 808 packages in 45s

120 packages are looking for funding
  run `npm fund` for details
sf --version                                                                                                                                                                                                                                                                                                                                                                           
 ›   Warning: @salesforce/cli update available from 2.33.3 to 2.35.6.
@salesforce/cli/2.33.3 darwin-arm64 node-v20.11.1

Weird issue, but at least it was only temporary! Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information required Issue requires more information or a response from the customer
Projects
None yet
Development

No branches or pull requests

2 participants