Go-ethereum: cant run eth.compile.solidity getting exit status 1 must provide file

Created on 24 Aug 2016  路  12Comments  路  Source: ethereum/go-ethereum

System information

Geth version: 1.5.0
OS & Version: OSX El capitan

I have been trying to run a compile with solidity and i keep getting the must provide file error

eth.compile.solidity("2")
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

any help would be greatly appericiated!

inactive

Most helpful comment

Got it working. Here's what I did. I'm on a Mac.

1) Uninstalled Ethereum using Brew, I was using 1.5.x unstable release. Re-installed latest stable release 1.4.18

2) This still didn't fix it. Uninstalled solidity:
npm uninstall solc -g

3) Installed solidity using Brew, now it works:

brew install solidity
brew linkapps solidity

All 12 comments

Try to use some proper solidity code, e.g.:

eth.compile.solidity("contract C{}")

You might want to take a look at http://ethereum.github.io/browser-solidity/#version=soljson-latest.js or install the standalone solidity compiler (instructions).

Which go-ethereum commit are you using? Which solc version?

With solidity 0.3.6 and geth from commit 5fc032a9d16ac6ea1dc020f06e44c24c94a361a7, I get

> eth.compile.solidity("2")
solc: exit status 1
/tmp/geth-compile-solidity901173321:1:1: Error: Expected import directive or contract definition.
2
^

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

i am using a proper contract now and it still does the same

contract example i use:
ontract Token {
mapping (address => uint) public balances;
event TokenSent(address sender, address receiver, uint amount);
function Token(uint supply) {
if (supply == 0) supply = 10000;
balances[msg.sender] = supply;
}
function send(address receiver, uint amount) returns (bool ok) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
TokenSent(msg.sender, receiver, amount);
return true;
}
}

[Error: solc: exit status 1
Must provide a file

What is your solidity version? (output of solc --version)

the output of solc --version is ERROR: Unknow opition --version what's wrong?

It sounds like your solidity installation is _very_ outdated. How did you install solidity?

I'm also getting this error: exit status 1 Must provide a file error

Unable to compile.solidity this line in my javascript file:

  var compiled = web3.eth.compile.solidity("contract C{}");
   console.log(compiled);

ERROR:
ORIGINAL EXCEPTION: solc: exit status 1
Must provide a file

solc --version
0.4.2+commit.af6afb04.mod.Emscripten.clang

Using: ethereum:web3 0.15.3

@chriseth any idea what the issue could be?

Got it working. Here's what I did. I'm on a Mac.

1) Uninstalled Ethereum using Brew, I was using 1.5.x unstable release. Re-installed latest stable release 1.4.18

2) This still didn't fix it. Uninstalled solidity:
npm uninstall solc -g

3) Installed solidity using Brew, now it works:

brew install solidity
brew linkapps solidity

This is also not working for me. Here's my system & software details:

$ ./geth version
Geth
Version: 1.4.18-stable-c72f5459
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.7.1
OS: linux
GOPATH=
GOROOT=/usr/lib/go-1.7
$ screenfetch
         _,met$$$$$gg.           resurtm@resurtm-desktop
      ,g$$$$$$$$$$$$$$$P.        OS: Debian testing stretch
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 4.7.0-1-amd64
   ,$$P'              `$$$.      Uptime: 4h 58m
  ',$$P       ,ggs.     `$$b:    Packages: 2565
  `d$$'     ,$P"'   .    $$$     Shell: bash 4.4.0
   $$P      d$'     ,    $$P     Resolution: 1920x1200
   $$:      $$.   -    ,d$$'     DE: XFCE
   $$\;      Y$b._   _,d$P'      WM: Xfwm4
   Y$$.    `.`"Y$$$$P"'          WM Theme: Next
   `$$b      "-.__               GTK Theme: Xfce-basic [GTK2]
    `Y$$                         Icon Theme: Tango
     `Y$$.                       Font: Sans 10
       `$$b.                     CPU: Intel Core i3 CPU 540 @ 3.067GHz
         `Y$$b.                  GPU: GeForce 9500 GT/PCIe/SSE2
            `"Y$b._              RAM: 4598MiB / 5961MiB
                `""""           
$ uname -a
Linux resurtm-desktop 4.7.0-1-amd64 #1 SMP Debian 4.7.8-1 (2016-10-19) x86_64 GNU/Linux

$ cat /proc/version 
Linux version 4.7.0-1-amd64 ([email protected]) (gcc version 5.4.1 20160904 (Debian 5.4.1-2) ) #1 SMP Debian 4.7.8-1 (2016-10-19)

$ cat /etc/debian_version 
stretch/sid
$ node --version
v6.9.1

$ npm --version
3.10.8

$ solcjs --version
0.4.3+commit.2353da71.Emscripten.clang

$ solc --version
0.4.3+commit.2353da71.Emscripten.clang

$ ls -la /usr/bin/solc*
lrwxrwxrwx 1 root root  6 Oct 31 16:47 /usr/bin/solc -> solcjs
lrwxrwxrwx 1 root root 31 Oct 31 16:32 /usr/bin/solcjs -> ../lib/node_modules/solc/solcjs

Here's how it does not work:

$ ./geth attach ipc:/home/resurtm/.ethereum/testnet/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.4.18-stable-c72f5459/linux/go1.7.1
coinbase: 0x1eded942353420c4ac3f3766ea858dff1f4afdca
at block: 1819615 (Mon, 31 Oct 2016 16:53:09 +06)
 datadir: /home/resurtm/.ethereum/testnet
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> var contract = eth.compile.solidity("contract test { function multiply(uint a) returns(uint d) { return a * 7; } }")
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:16

> 

Also reported here: https://github.com/ethereum/solc-js/issues/68#issue-186255964

@cesargalindo @resurtm you are using the javascript commandline interface to the solidity compiler together with geth. Only the native binary commandline compiler works together with geth. It would not be a good idea to send a message to geth from javascript so that it invokes a new javascript process. Instead, you should compile your source in the javascript environment directly.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keitaj picture keitaj  路  3Comments

JMaxU picture JMaxU  路  3Comments

VenusHu picture VenusHu  路  3Comments

VoR0220 picture VoR0220  路  3Comments

freshonline picture freshonline  路  3Comments