crytic / solc-select

Manage and switch between Solidity compiler versions
GNU Affero General Public License v3.0
758 stars 103 forks source link

/usr/local/bin/solc: Permission denied #15

Closed svidorozhd closed 3 years ago

svidorozhd commented 5 years ago

I tried to install solc-select as specified in the "Quickstart" description. When asked to overwrite /usr/local/bin/solc, the error, described in the title, occurs. Using -privileged flag in the Docker call does not solve this problem.

KiriKiri commented 5 years ago

The same thing, macOS Mojave 10.14.3

ESultanik commented 5 years ago

I suspect the issue is one of the following:

  1. You do not have Homebrew installed;
  2. Homebrew is misconfigured; or
  3. Your user does not have permission to write to /usr/local/bin.

If it's #1, then the easiest solution is to install Homebrew. To diagnose the other possibilities, what is the result of running ls -lad /usr/local/bin?

Alternatively, you can always install it to a different directory in your PATH by setting the PREFIX environment variable to the desired installation path before running the quickstart instructions.

pcowgill commented 5 years ago

To diagnose the other possibilities, what is the result of running ls -lad /usr/local/bin?

I'm having the same issue, and for me the result is: drwxrwxr-x 239 paulcowgill admin 7648 May 22 16:04 /usr/local/bin

shayanb commented 5 years ago

I have the same issue on 10.14.4.

Also tried removing solc brew uninstall solidity, this command docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e runs with no output and yet -bash: solc: command not found

svidorozhd commented 5 years ago

To diagnose the other possibilities, what is the result of running ls -lad /usr/local/bin?

My result is: admin 3584 17 Mai 23:15 /usr/local/bin

n0thingness commented 5 years ago

After pulling the image, I was having a lot of difficulty getting the docker run command working. It seemed to be failing silently. Removing the -e at the end of the command resulted in this error: bash: line 25: /usr/local/bin/solc: Permission denied.

So I tried installing in a different location:

export PREFIX=/usr/local
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash

This seemed to install solc successfully. But then, running the command solc --version resulted in -bash: /usr/local/bin/solc: Permission denied.

cd /usr/local/bin
chmod u+x solc

After that, solc seems to be working as expected. Hope this helps.

nevillegrech commented 5 years ago

Similar issue here:

Overwrite /snap/bin/solc? [yN] y
bash: line 25: /snap/bin/solc: Permission denied

which I solved initially, but then I couldn't get to run solc:

$ solc --help
mount: mounting /usr/bin on /workdir/usr/bin failed: Permission denied
mount: mounting /bin on /workdir/bin failed: Permission denied
mount: mounting /dev on /workdir/dev failed: Permission denied
mount: mounting /proc on /workdir/proc failed: Permission denied
mount: mounting /sys on /workdir/sys failed: Permission denied
chroot: can't execute 'chroot.sh': No such file or directory
naddison36 commented 5 years ago

I tried installing solc-select on my Mac as per the README instructions but it silently failed

[~]$ docker pull trailofbits/solc-select
Using default tag: latest
latest: Pulling from trailofbits/solc-select
Digest: sha256:d2e0ba8806e48ee449eeb0e70dabcb22be6c20f049f1b4f6cecd228cae17090a
Status: Image is up to date for trailofbits/solc-select:latest
[~]$ docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e
[~]$ solc --version
-bash: solc: command not found

Trying again without the -e gave the follow

docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash
Overwrite /usr/local/bin/solc? [yN] y
bash: line 51: /usr/local/bin/solc: Permission denied
Installed solc to /usr/local/bin/solc

The same result if I ran it using sudo

My solc was previously installed using brew

[~]$ ls -l `which solc`
lrwxr-xr-x  1 nicholasaddison  wheel  34 14 Aug 08:29 /usr/local/bin/solc -> ../Cellar/solidity/0.5.11/bin/solc

After removing /usr/local/bin/solc, the script fails with as the default location is solc is not installed is /usr/bin/solc and not /usr/local/bin/solc

[~]$ docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash
bash: line 51: /usr/bin/solc: Operation not permitted

I tried installing using to a different location using the PREFIX env variable, but that doesn't work either

[~]$ mkdir solc-select
[~]$ cd solc-select/
[solc-select]$ export PREFIX=~/solc-select
[solc-select]$ mkdir bin
[solc-select]$ touch bin/solc
[solc-select]$ docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash
Overwrite /Users/nicholasaddison/solc-select/bin/solc? [yN] y
Installed solc to /Users/nicholasaddison/solc-select/bin/solc
[solc-select]$ chmod u+x ./bin/solc
[solc-select]$ ./bin/solc --version
Error loading shared library libreadline.so.8: No such file or directory (needed by /usr/bin/solc)
Error relocating /usr/bin/solc: unstifle_history: symbol not found
Error relocating /usr/bin/solc: rl_make_bare_keymap: symbol not found
Error relocating /usr/bin/solc: rl_bind_key_if_unbound_in_map: symbol not found
Error relocating /usr/bin/solc: rl_macro_dumper: symbol not found
Error relocating /usr/bin/solc: previous_history: symbol not found
Error relocating /usr/bin/solc: rl_vi_end_word: symbol not found
brockelmore commented 5 years ago

For those who encounter this later, I had the same problem. Either was getting permission denied, operation not permitted, or error relocating.

I took the following steps to get it to work:

export PREFIX=/Users/brockelmore/solc-select
docker pull trailofbits/solc-select
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e
sudo ln -s /Users/brockelmore/solc-select/bin/solc /usr/local/bin

Basically, all I am doing is building in a known permitted location via PREFIX then symlinking back to /usr/local/bin so that I can run the executable from everywhere and applications like slither can access the executable.

arcz commented 3 years ago

This shouldn't be a problem anymore as we changed solc-select to be a Python package https://github.com/crytic/solc-select/releases/tag/0.2.0.