-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Docker solc standard-json error everytime #11543
Comments
Docker by default will not pass standard input to the container it runs. You need to add the docker run --interactive ethereum/solc:0.8.5 --standard-json < ./src/Compiler/001/config.json By the way, if you're just running it manually (i.e. not as a part of some server orchestration where you'd want to inspect the dead container if it crashes), it's a good idea to the Also, if you want to be able to interact with a program from the terminal (typing text, etc.) instead of giving it a file you should also add This is not a bug in the compiler so I'm closing the issue but feel free to ask if you some other problems :) |
Yes, that made everything, it was a basic docker thing i forgot.. thanks you ! now i can start to really learn about the compiler (and i have a lot of work..) |
Try |
Yea i cleaned everything, it's quite pretty now ! But now, i have a problem with json and sources. Even with base-path or allow-paths, the json cannot find the file (relative or absolute) I think it's me that does not really understand the doc of all about path/remapping etc.. I'm trying to do a simple way
with :
result to : I tried different combo with base-path, allow-paths, url etc.. i can't find the right and simple way to get to the contract |
Try this: docker run \
--rm \
--volume "$PWD/src/Contract:/project/src/Contract" \
--workdir /project \
ethereum/solc:0.8.4 \
--standard-json src/Compiler/001/config.json \
--allow-paths /project | jq --indent 4 Explanation:
Also, an unrelated question: I see you switched from 0.8.5 to 0.8.4. Was it by chance because you ran into #11522 or some other reason? |
I think that point was written with
Yeah, if you got this, then stuff got compiled successfully.
Pure command-line interface is going to be more convenient if you are running the compiler directly. It does have some quirks around But to be honest most people do not use the compiler directly. They use it through a framework like Truffle, Hardhat or Brownie or an IDE extension like vscode-solidity. The framework typically downloads and manages compiler binaries for you. Under the hood these frameworks use Standard JSON.
OK. Makes sense. I'm asking because I'm interested in how widespread that issue is. I.e. are users running into it often in practice. Everything indicates that it is and we're actually planning to release 0.8.6 with a fix pretty soon. |
Sorry for time, i couldn't put my head on it since last time ^^ So, ok, i will get out of JSON for now and go for a pure command-line (with makefile it won't be so hard to do so automated) I will of course participate to the documentation, at least if i see some point that need more information. I understand that ppl use some external framework or others, but as i want to understand how everything work, i prefer not to use any external tools as possible ^^ Ok for the unreachable, i'll look for this update then cause it's quite annoying those unreachable code ^^ |
Just FYI: 0.8.6 is already out so it's no longer an issue. |
Hi, so i worked a bit, and now i don't use json anymore.
First thing is, i don't know if it intended, but, the system can't create folders if they does not exists.
I still need to '--allow-paths .' to make the usable (so it does not take in action that we are in the right folder..) And then, after those setted up, the third i can't explain : can't write file.. |
I just checked and it does work for me: mkdir -p src/Contract/
echo "contract C {}" > src/Contract/Contract-001.sol
docker run \
--rm \
--volume $PWD/src:/sources \
--workdir /sources \
ethereum/solc:0.8.6 \
--output-dir Compiler/001/Output \
--abi \
--bin \
Contract/Contract-001.sol
ls src/Compiler/001/Output/
Do you have any symlinks in your paths?
This looks as if the directory exists but the compiler cannot write there. You should check what are the permissions for that directory and which user owns it. |
Ok, ok.. you wanna laugh ? While trying to get rid of "root" problem of docker (you know, when you let the container create folder and file, that make your local folder owned by root and it's annoying) edit : like now, i can't remove the Compiler folder unless i go with sudo.. and all work now, thanks ! To the next problem now ^^ Edit 2 : Yea, still need allow-path though. i haven't any symlink or anything, i just have some relative-path inside of my files |
Even in the example I gave with that same exact code? If not, maybe you could give me a small self-contained example so that I can reproduce it? BTW, here's a clarification for the docs about docker volumes: #11576. Could you take a look and tell me if it's better now? |
With your example, there is no problem, since the contract does not use any imported file. Here is my workspace atm : and the zip containe my "src" folder, as i have right now you will see that the Contract_001 import BaseContract, wich import some others files everywhere
I think it's already clearer ! With the link to the right chapter of the doc, one could easily understand the difference between the code written inside the JSON, and the code in external file, imported via the url option. |
Oh. I thought it was complaining about By default you can only import files that are in the same directory as the files you specified on the command line (or its subdirectories). In your case that's files inside |
Yea, that's it so alright then, i'll use --alow-path . with the workdir it's ok, meaning that everything inside the folder is ok to use. and that's why, it does not complain about the "basecontract" because it's on the same folder, logic. it's a nice security feature that i did not understand first |
Hi !
I am quite new in solidity, so i try to setup a dev environment with docker.
So on my test, i try to compile contract with the json way that seems to be the recommended one.
docker run ethereum/solc:0.8.5 --standard-json < ./src/Compiler/001/config.json
and the output is, no matter what is the version of solc, or no matter what i put in my json :
{"errors":[{"component":"general","formattedMessage":"* Line 2, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n","message":"* Line 2, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n","severity":"error","type":"JSONError"}]}
Even with a simple json code like this :
{ "language": "Solidity", "sources": { "": { "content": "contract C { uint[] constant c; }" } } }
The text was updated successfully, but these errors were encountered: