facebook / idb

idb is a flexible command line interface for automating iOS simulators and devices
https://fbidb.io
MIT License
4.46k stars 434 forks source link

install: PermissionError: [Errno 13] Permission denied: '/usr/local/protoc_compiler_template.py' #620

Open voxspox opened 3 years ago

voxspox commented 3 years ago

Description

I want to install idb on a maxOs Catalania 10.15.6

% brew tap facebook/fb
% brew install idb-companion

-> ok

% pip3 install fb-idb
Collecting fb-idb
  Using cached fb_idb-1.0.12-py3-none-any.whl (125 kB)
Requirement already satisfied: treelib in ./lib/python3.8/site-packages (from fb-idb) (1.6.1)
...
Requirement already satisfied: hyperframe<6,>=5.2.0 in ./lib/python3.8/site-packages (from h2->grpclib>=0.3.2->fb-idb) (5.2.0)
Installing collected packages: fb-idb
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/protoc_compiler_template.py'
Consider using the `--user` option or check the permissions.

% ls /usr/local/lib/python3.8/site-packages
fb_idb-1.0.12.dist-info
idb
...

% idb
zsh: command not found: idb

Solution

Maybe the setup.py must be fixed to not access /usr/local for temporary files??

Additional Information

none

phillipkey commented 3 years ago

i ran into this issue today and the fix for me was to add the python lib to my PATH

export PATH="$PATH:/Users/[username]/Library/Python/3.8/bin"

in my .zshrc fixed for me

josmithua commented 3 years ago

I ran sudo pip3 install fb-idb but I had to pip3 uninstall fb-idb before I tried to install it again.

michaek commented 3 years ago

Installing with sudo (root privileges) is a way to avoid this error, but it's probably not how one would want to handle this. After all, when doing so pip prints "WARNING: Running pip as root will break packages and permissions." That's a reasonable warning!

The reporter's suggestion that setup.py should be changed to avoid writing to /usr/local is most likely correct, as it seems that os.path.dirname(__file__) is returning /usr/local even when the file is located in another (user-writable) location. Possibly this can be resolved by wrapping in os.path.realpath to compensate for any symlinks?

michaek commented 2 years ago

@jackkinsella I'm glad that's working for you, but the original reporter shows that they were using pip3, so I expect that may not be a general solution.

alexchandel commented 2 years ago

This happens for me every install, for every supported version of Python. Running pip install fb-idb a second time produces no error, but also fails to install idb.

truebit commented 1 year ago

still occurs in macOS Big Sur v11.6.4 with brew installed python3.10

GuillaumeHemmen commented 1 year ago

Using the --user option as recommended solved this issue for me.

MVenell commented 1 year ago

Don't use sudo, because it is not recommended. This works:

pip install --user fb-idb

If you get "idb: command not found" after successful installation, idb is installed in the directory that is not in the PATH.

find / -name "idb"

Then you know where it is and either add that directory to the PATH or move idb to some place which is in the path.