question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

solc.compile_source() Failed

See original GitHub issue
  • py-solc Version: 2.1.0
  • solc Version: 0.4.21 (here is solcjs)
  • Python Version: 3.5.4
  • OS: linux(ubuntu)

What was wrong?

Use compile_source(source) fail !!

My commands:

Install solc: npm install -g solc Install py-solc: pip3 install py-solc Use solc in python3: from solc import compile_source compile_source(‘pragma solidity ^0.4.0; contract A{ funcion A() public{}}’)

Details:

Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/usr/local/lib/python3.5/dist-packages/solc/main.py”, line 106, in compile_source stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs) File “/usr/local/lib/python3.5/dist-packages/solc/utils/string.py”, line 85, in inner return force_obj_to_text(fn(*args, **kwargs)) File “/usr/local/lib/python3.5/dist-packages/solc/wrapper.py”, line 165, in solc_wrapper stderr_data=stderrdata, solc.exceptions.SolcError: An error occurred during execution command: solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc return code: 1 stderr:

stdout: Must provide a file

Cute Animal Picture

put a cute animal picture here. animals-smile_3379238k

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dylanjwcommented, Mar 28, 2018

Its possible that @ajax-2 hit another issue before hitting the syntax error. When I ran the example snippet I got:

        <stdin>:1:46: Error: Expected token Semicolon got 'LParen'
pragma solidity ^0.4.0; contract A{ funcion A() public{}}

I am using the apt packaged solc. Im wondering if the version of solc installed by the npm package is different than the regular solc binary. I also thought that the npm solc command was “solcjs”, which definitely does behave differently.

EDIT: @ajax-2 It does appear you are using solcjs instead of the solc binary. Did you link the solcjs executable to solc? I would remove that link and install the solc binary via apt:

sudo apt-get install solc

Example showing solcjs error output when piping the source:

$ echo 'pragma solidity ^0.4.0; contract A{ function A() public{}}'|solcjs --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc
Must provide a file
1reaction
dylanjwcommented, Mar 28, 2018

There is a typo in your solidity snippet. Missing the T in function. Should be:

compile_source('pragma solidity ^0.4.0; contract A{ function A() public{}}')
Read more comments on GitHub >

github_iconTop Results From Across the Web

compile error · Issue #417 · ethereum/solc-js - GitHub
my code pragma solidity ^0.5.0; contract CourseList { address public ceo; constructor() public{ ceo = msg.sender; } } the compile code const ...
Read more >
Solcx compile source is throwing error - error occurred during ...
SolcError: An error occurred during execution > command: `C:\Users\Nikesh\.solcx\solc-v0.8.11\solc.exe --help -` > return code: ` ...
Read more >
Source file compile error - solidity - Ethereum Stack Exchange
Source file requires different compiler version (current compiler is 0.8.2+commit.661d1103.Emscripten.clang) - note that nightly builds are ...
Read more >
How to use the solc.compile function in solc - Snyk
To help you get started, we've selected a few solc.compile examples, based on popular ways it is used in public projects.
Read more >
solc-typed-ast
Documentation for solc-typed-ast. ... for (const error of failure.errors) { ... It is able to compile the Solidity source and output short AST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found