Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Downloading compiler #2631

Closed
codepandy opened this issue Nov 21, 2019 · 21 comments
Closed

Downloading compiler #2631

codepandy opened this issue Nov 21, 2019 · 21 comments
Assignees
Labels
error better issue indicates improvement to error messaging priority2 ⚠️

Comments

@codepandy
Copy link

truffle compile

then

Compiling your contracts...
===========================
⠹ Downloading compiler. Attempt #1
@ilifewebdev
Copy link

me too ,same problem

@CruzMolina
Copy link
Contributor

CruzMolina commented Nov 26, 2019

Hey @shch & @codepandy , can you provide full reproduction steps?

Which versions of Node, Truffle, & Solidity are you using while this error is happening?
Does Truffle provide an error or does the process just hang?

@ChaoChason
Copy link

Hey @shch & @codepandy , can you provide full reproduction steps?

Which versions of Node, Truffle, & Solidity are you using while this error is happening?
Does Truffle provide an error or does the process just hang?

me too ,same problem ,just hang,No report error .

Truffle v5.1.2 (core: 5.1.2)
Solidity v0.5.12 (solc-js)
Node v13.2.0
Web3.js v1.2.2

@ChaoChason
Copy link

Hey @shch @codepandy @CruzMolina

After a long wait, it can finally be executed. Guess what it's running in the background, and it's fast to execute now. It's so sad that there is no error.

@leojames
Copy link

me too . The same question

i-qcloud527:pet root# truffle compile

Compiling your contracts...

⠼ Fetching solc version list from solc-bin. Attempt #1

@leojames
Copy link

Hey @shch @codepandy @CruzMolina

After a long wait, it can finally be executed. Guess what it's running in the background, and it's fast to execute now. It's so sad that there is no error.

Do you slove it ? it need to download something or Bug ?

@eggplantzzz
Copy link
Contributor

Hey everyone, is this still a problem for you? We'd like to know if we can do something about it if so, thanks y'all!

@lychees
Copy link

lychees commented Jun 25, 2020

Seconded.

截屏2020-06-24 下午8 51 07

@snowkidind
Copy link

snowkidind commented Jun 26, 2020

A POSSIBLE SOLUTION / HACK

NOTE: OSX 10.14.6

frustrating. it compiles using open zeppelin cli.
installed locally, using npx truffle console

truffle(development)> version
Truffle v5.1.32 (core: 5.1.32)
Solidity - 0.6.2 (solc-js)
Node v13.7.0 (also tried with v10.19.0 and v12.16.1)
Web3.js v1.2.1

Compiling your contracts...
✔ Fetching solc version list from solc-bin. Attempt #1
✔ Downloading compiler. Attempt #1.
✔ Downloading compiler. Attempt #2.
✔ Downloading compiler. Attempt #3.
Error: Could not find a compiler version matching 0.6.2. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.

On using npx truffle obtain 0.6.2

✔ Downloading compiler. Attempt #3.
Unbox failed!

Note I can (and have) try to download and build 0.6.2, or find a binary. But determining how to install these manually is ambiguous.

BUT....

sudo npx truffle compile appears to solve the problem.

Compiling your contracts...
✔ Fetching solc version list from solc-bin. Attempt #1
✔ Downloading compiler. Attempt #3078 
> Compiling contracts/p.sol
> Artifacts written to /Users/keny/Desktop/ERC20/p/build/contracts
> Compiled successfully using:
   - solc: 0.6.2+commit.bacdbe57.Emscripten.clang

So I would say the solution has something to do with permissions when downloading the file but the error reporting is ambiguous as it does not say there was a permissions error.

 ls -al /Users/keny/.config/truffle/compilers/node_modules 
-rw-r--r--  1 root        staff  7985148 Jun 26 23:27 soljson-v0.6.2+commit.bacdbe57.js
ls -al /Users/keny/.config/truffle/compilers/
drwxr-xr-x  4 root        staff   128 Jun 26 23:27 node_modules

Now it appears to work. My thought is that truffle (this didnt work on a global install either) is unable to write a downloaded file into its compilers directory because apple is running some sort of gatekeeper and the program is not asking for permission to install thing downloaded from the interwebs.

Finally, after running sudo it appears to subsequently work, because it no longer needs to download the compiler into the directory.

@lychees
Copy link

lychees commented Jun 30, 2020

@snowkidind
It works.

@haltman-at
Copy link
Contributor

Question for the people experiencing this issue. When you installed Truffle, did you use sudo or otherwise do it with root permissions? That may be the source of the problem. Thanks!

@snowkidind
Copy link

Local install, not global. sudo should not be required. But it's trying to install a compiler in a root - owned directory per my comment above.

@eggplantzzz
Copy link
Contributor

eggplantzzz commented Jul 8, 2020

I would say try using nvm or some other node version manager in this case. When you use nvm and npm it designates a different directory for installed packages which prevents permissions issues.

If anyone tries using nvm with npm to install and use Truffle can they let me know whether it resolves this problem?

@snowkidind
Copy link

Now that I understand the issue it's easy to resolve, but my notes point out that the error messages are pointing at the wrong error causing overall confusion. It looks like a failed download when it's a permissions error.

@gnidan
Copy link
Contributor

gnidan commented Jul 15, 2020

Sounds like there's more we can do here to make the experience more clear. Calling this one "error better" and getting it onto our backlog. Thanks for the investigation everyone, and sorry for the inconvenience!

@gnidan gnidan added error better issue indicates improvement to error messaging priority2 ⚠️ and removed needs investigated needs reproduced labels Jul 15, 2020
@eggplantzzz
Copy link
Contributor

Is there something actionable here? Just evaluating whether we can close this.

@gnidan
Copy link
Contributor

gnidan commented Mar 30, 2022

Seems like there's an action here to, upon error obtaining solc, detect the permissions of the compilers cache directory and, if the permissions are insufficient, suggest they rimraf the whole computer or something.

cc @cds-amal

@inglkruiz
Copy link

Hi, I just wanted to post what worked for me. For quick context, I'm deploying a Web IDE on K8s Environment which does not have access to internet. I built a container image with all the files I needed, pakcage.json, node_modules, etc.. For including the soljson-v... used by truffle I run when build the image

RUN npx truffle obtain --solc 0.8.3 && \
  npx truffle obtain --solc 0.8.9 && \
  npx truffle obtain --solc 0.8.11 && \
  npx truffle obtain --solc 0.8.14

That command created the following folder /root/.config/truffle/compilers/node_modules/ and /root/.config/truffle-nodejs/compilers/node_modules/ so I had to create the same folder for the user I set to run the container using the following:

RUN mkdir -p /home/coder/.config/truffle/compilers/node_modules && \
  mkdir -p /home/coder/.config/truffle-nodejs/compilers/node_modules && \
  cp -R /root/.config/truffle/compilers/node_modules/* /home/coder/.config/truffle/compilers/node_modules/ && \
  cp -R /root/.config/truffle-nodejs/compilers/node_modules/* /home/coder/.config/truffle-nodejs/compilers/node_modules/

RUN chown -R $UID:$UID /home/coder && \
  chmod -R 777 /home/coder

Altogether the last lines of my Dockerfile looks like this

RUN npx truffle obtain --solc 0.8.3 && \
  npx truffle obtain --solc 0.8.9 && \
  npx truffle obtain --solc 0.8.11 && \
  npx truffle obtain --solc 0.8.14

WORKDIR /home/coder/project

ENTRYPOINT ["dumb-init", "fixuid", "-q", "/usr/local/bin/code-server", "--host", "0.0.0.0", "--disable-updates", "--disable-telemetry", "/home/coder/project"]

USER root

RUN mkdir -p /home/coder/.config/truffle/compilers/node_modules && \
  mkdir -p /home/coder/.config/truffle-nodejs/compilers/node_modules && \
  cp -R /root/.config/truffle/compilers/node_modules/* /home/coder/.config/truffle/compilers/node_modules/ && \
  cp -R /root/.config/truffle-nodejs/compilers/node_modules/* /home/coder/.config/truffle-nodejs/compilers/node_modules/

RUN chown -R $UID:$UID /home/coder && \
  chmod -R 777 /home/coder

USER $UID

I hope this helps someone.

@benjamincburns
Copy link
Contributor

Hi @inglkruiz,

Just a tip in case you aren't aware, the .config directory is being created under the /root directory during your docker build, because the docker build defaults to running as root within the temporary build containers that docker sets up when running docker build.

Assuming that coder is a known user inside of your docker image, you could likely switch to that user via the USER coder directive prior to running the npx truffle obtain ... commands.

If the coder user is not known to your environment, you could add it by doing RUN useradd -Dm coder, and then switch to it using the USER coder directive.

If that still doesn't fix the issue, try wrapping your command in a bash login console, like so:

USER coder
RUN /usr/bin/env bash -lc 'for VERSION in 0.8.3 0.8.9 0.8.11 0.8.14 do; npx truffle obtain --solc $VERSION; done'

@revoltez
Copy link

revoltez commented Aug 3, 2022

i changed the ownership of ~/.config/truffle-nodejs and it worked
chown userName -R ~/.config/truffle-nodejs
in my case the problem was that the file was locked to use only by root even though i never installed truffle using sudo

@lsqproduction
Copy link
Contributor

Closing for issue maintenance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
error better issue indicates improvement to error messaging priority2 ⚠️
Projects
None yet
Development

No branches or pull requests