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

solcjs not compatible with console #57

Closed
louisabraham opened this issue Sep 24, 2016 · 3 comments
Closed

solcjs not compatible with console #57

louisabraham opened this issue Sep 24, 2016 · 3 comments

Comments

@louisabraham
Copy link

louisabraham commented Sep 24, 2016

Hi, I'm having an issue with solcjs when I try to compile something from the console :

> admin.setSolc("/usr/local/bin/solcjs")
"0.4.2+commit.af6afb04.mod.Emscripten.clang\n\npath: /usr/local/bin/solcjs"
> eth.compile.solidity('contract C{}')
solc: exit status 1
Must provide a file

Specify --help for available options

    at web3.js:3119:20
    at web3.js:6023:15
    at web3.js:4995:36
    at <anonymous>:1:1

I did not understand until I setSolc to a debugging python program :

import sys
print(sys.stdin.read(), file=sys.stderr)
print(sys.argv, file=sys.stderr)
sys.exit(1)

(when you use setSolc, you have to return an exit code of 0, but you can modify the program again before you compile)

The issue seems to be that solcjs has no input_file parameter, and is passed the program via stdin.
Is it possible to modify it to accept input from stdin ?

@louisabraham louisabraham changed the title Read input from stdin solcjs not compatible with console Sep 24, 2016
@louisabraham
Copy link
Author

louisabraham commented Sep 24, 2016

The command is called with args : '--bin', '--abi', '--userdoc', '--devdoc', '--add-std', '--optimize', '-o', '/var/folders/ns/bvd4v4bd62jg8qvwyn02dtdh0000gn/T/solc719193878'

I tried to use the soljs compiler anyway, replacing again the command with a python script :

import sys
import subprocess

tmp = subprocess.check_output("echo $TMPDIR".split()).decode()
inp = sys.stdin.read()
args = ["/usr/local/bin/solcjs"] + sys.argv[1:]
if inp:
    path = tmp + "solcc123123"
    open(path, 'w').write(inp)
    subprocess.call(args + [path])
else:
    subprocess.call(args)

I get now the error :

solc: error reading user doc: open /var/folders/ns/bvd4v4bd62jg8qvwyn02dtdh0000gn/T/solc515219141/C.docuser: no such file or directory

And indeed, none of the options '--userdoc', '--devdoc', '--add-std' is listed in the --help menu of solcjs.
How am I supposed to use solcjs with the console ? It would be really great, because solcjs is far more simple to deploy than the cpp implementation that needs to be compiled.

@chriseth
Copy link
Contributor

If you use solc-js, you can call compile as a native javascript function, instead of using eth.compile.solidity. solc-js is not compatible with setSolc, these are just two completely different programs.

@axic
Copy link
Member

axic commented Oct 21, 2016

Duplicate of #43.

@axic axic closed this as completed Oct 25, 2016
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