4

I can't install solc on Mac OS X. I have tried the following:

npm install solc 

/Users/punddalinni
└── solc@0.3.0-1 
npm WARN enoent ENOENT: no such file or directory, open '/Users/punddalinni/package.json'
npm WARN punddalinni No description
npm WARN punddalinni No repository field.
npm WARN punddalinni No README data
npm WARN punddalinni No license field.

When I go back to geth, and I run

> eth.getCompilers()
[""]

When I tried to setSolc the following happened

> admin.setSolc('/Users/punddalinni/node_modules/solc')
exec: "/Users/punddalinni/node_modules/solc": permission denied
    at InvalidResponse (<anonymous>:-81662:-57)
    at send (<anonymous>:-156322:-57)
    at setSolc (<anonymous>:-133322:-57)
    at <anonymous>:1:1

I have tried following the directions here but it gets stuck at

brew install llvm --HEAD --with-clang

EDIT: Including contents of package.json from solc in Mac.

{
  "_args": [
    [
      "solc",
      "/Users/punddalinni"
    ]
  ],
  "_from": "solc@latest",
  "_id": "solc@0.3.0-1",
  "_inCache": true,
  "_installable": true,
  "_location": "/solc",
  "_nodeVersion": "4.0.0",
  "_npmOperationalInternal": {
    "host": "packages-13-west.internal.npmjs.com",
    "tmp": "tmp/solc-0.3.0-1.tgz_1457892692634_0.5487515390850604"
  },
  "_npmUser": {
    "email": "d11e9@turkd.net",
    "name": "d11e9"
  },
  "_npmVersion": "3.3.2",
  "_phantomChildren": {},
  "_requested": {
    "name": "solc",
    "raw": "solc",
    "rawSpec": "",
    "scope": null,
    "spec": "latest",
    "type": "tag"
  },
  "_requiredBy": [
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz",
  "_shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
  "_shrinkwrap": null,
  "_spec": "solc",
  "_where": "/Users/punddalinni",
  "author": {
    "name": "chriseth"
  },
  "bugs": {
    "url": "https://github.com/chriseth/browser-solidity/issues"
  },
  "dependencies": {},
  "description": "Solidity compiler",
  "devDependencies": {},
  "directories": {},
  "dist": {
    "shasum": "523e79db0c69070f91fcbf408e8c7d0c93be176c",
    "tarball": "http://registry.npmjs.org/solc/-/solc-0.3.0-1.tgz"
  },
  "gitHead": "5ce686c8d33db78c8f1eb8e2318eefbc5151f0eb",
  "homepage": "https://github.com/chriseth/browser-solidity#readme",
  "keywords": [
    "compiler",
    "ethereum",
    "solidity"
  ],
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "chriseth",
      "email": "c@ethdev.com"
    },
    {
      "name": "d11e9",
      "email": "d11e9@turkd.net"
    }
  ],
  "name": "solc",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/chriseth/browser-solidity.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "version": "0.3.0-1"
}

Any ideas?

3

I wasn't familiar with NPM, so had some similar issues. Simply running npm install solc will attempt to install locally, which can present some permission and linking issues- this is likely the cause of the problem.

Instead, install solC globally by using $ npm install -g solc (you may also want to try $ npm install solc --global as I'm not sure which of these two commands fixed my issue).

If this is installed, check where it's been installed by running $ which solcjs which should yield something like /usr/local/bin/solcjs

I found that I needed to also use Homebrew to install/build solC, following the installation instructions. Once Brew was done, I checked that solC was installed with $ which sol.

Copy this directory, then once you've launched geth console use it in the setSolc command, like > admin.setSolc("/usr/local/bin/solc")

With luck, you'll get a confirmation message, and the next time your run > eth.getCompilers() the result should be something like ["Solidity"]

1

Ah...you are using this wrong. Web3 tutorials don't reflect this but there is a difference between the way you set up Solidity to compile on web3 with the built from source compiler (which is what web3 assumes) and the npm package (which the tutorials don't revolve around). In order to get things compiling, you'll need to follow the instructions per the Browser-solidity page:

https://github.com/chriseth/browser-solidity

Excerpt:

var solc = require('solc');
var input = "contract x { function g() {} }";
var output = solc.compile(input, 1); // 1 activates the optimiser

for (var contractName in output.contracts) {
    // code and ABI that are needed by web3
    console.log(contractName + ': ' + output.contracts[contractName].bytecode);
    console.log(contractName + '; ' + JSON.parse( output.contracts[contractName].interface));
}
  • I tried running that from inside geth but get this > var solc = require('solc'); Cannot find module 'solc' at a (<anonymous>:-160:-28) at require (<anonymous>:-122:-28) at <anonymous>:1:12 Also, is this a OS X issue? Because I also use an Ubuntu testchain and to compile contracts there I simply follow the usual steps, as described here (setting source = minifiedContract, etc.) – punddalinni Mar 28 '16 at 22:00
  • Nope. Not an issue that we're aware about in either. Can you list the contents of your package.json? – VoR0220 Mar 29 '16 at 0:41
  • Added it to the question. – punddalinni Mar 29 '16 at 12:39
  • No, not the solc package.json, your personal package.json, the one where you're creating the project out of. – VoR0220 Mar 29 '16 at 18:15
  • Sorry, but I'm new at this am I don't think I'm understanding what you're saying. Which directory should that be in? – punddalinni Mar 30 '16 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.