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

Standard JSON compilation cannot find or read files. #2266

Closed
pipermerriam opened this issue May 12, 2017 · 3 comments
Closed

Standard JSON compilation cannot find or read files. #2266

pipermerriam opened this issue May 12, 2017 · 3 comments

Comments

@pipermerriam
Copy link
Member

The compiler throws an error when trying to compile using the --standard-json flag when reading from a file.

echo '{"language": "Solidity", "sources": {"Greeter.sol": {"urls": ["file:///Users/piper/sites/py-solc/tmp/Greeter.sol"]}}}' | solc --standard-json
{"contracts":{},"errors":[{"component":"general","formattedMessage":"Cannot import url (\"file:///Users/piper/sites/py-solc/tmp/Greeter.sol\"): Unknown exception in read callback.","message":"Cannot import url (\"file:///Users/piper/sites/py-solc/tmp/Greeter.sol\"): Unknown exception in read callback.","severity":"error","type":"IOError"}],"sources":{}}

I've also tried the following formats for the file path just in case I was formatting something a little wrong:

  • file:///Users/piper/sites/py-solc/tmp/Greeter.sol
  • file://Users/piper/sites/py-solc/tmp/Greeter.sol
  • file://tmp/Greeter.sol
  • file://./tmp/Greeter.sol
  • tmp/Greeter.sol
  • /Users/piper/sites/py-solc/tmp/Greeter.sol

Help please

@axic
Copy link
Member

axic commented May 12, 2017

solc at the moment doesn't support URL prefixes, such as file:// (tracked in #2157), but using it in for example browser-solidity should be possible.

For regular paths, the paths must first be whitelisted via --allow-paths <path1>,<path2>,... So for your use case, it should be echo .. | solc --allow-paths tmp --standard-json.

Also --allow-paths cannot handle trailing forward slashes yet (see #2147).

@pipermerriam
Copy link
Member Author

That got things working, though I had to use absolute paths for everything as I wasn't able to get any form of relative path to work for either the allow-paths value or the paths passed in via standard json.

@MicahZoltu
Copy link
Contributor

Workaround is to provide an absolute path to to some ancestor directory as an --allow-paths parameter and then include a full path to the file as one of the urls in --standard-json.

echo '{"language": "Solidity", "sources": { "file.sol": { "urls": [ "/full/path/to/file.sol" ] } } }' | solc --allow-paths /full/path --standard-json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants