Truffle: deployer.exec command produces error during migration

Created on 8 Nov 2016  路  5Comments  路  Source: trufflesuite/truffle

Issue

Running truffle migrate produces error

Steps to reproduce

  1. Create a script according to https://truffle.readthedocs.io/en/latest/getting_started/scripts/
  2. Add deployer.exec command to migration jobs
module.exports = function(deployer) {
  deployer.exec('path/to/script');
}
  1. Run truffle migrate

Expected behavior

Script runs and exits successfully

Actual behavior

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Expected parameter 'contracts_build_directory' not passed to function.
    at /Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/expect.js:5:15
    at Array.forEach (native)
    at Object.options (/Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/expect.js:3:19)
    at Object.exec (/Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/require.js:89:12)
    at /Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/deployer.js:101:17
    at /Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/deployer.js:100:14
    at /Users/teddy/Projects/btl/truffle-webpack-demo-clone/node_modules/truffle/lib/deferredchain.js:20:15

Environment

  • Truffle 2.1.1
  • Node 7.0.0
  • TestRPC 3.0.0
  • macOS Sierra
  • npm 3.10.8

Most helpful comment

Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
at XMLHttpRequest.request.onreadystatechange (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:115:32)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpRequestError (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
at ClientRequest. (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:309:9)
at emitOne (events.js:96:13)

All 5 comments

299

I get the following error on a brand new project:

 truffle migrate
Error: Invalid JSON RPC response: "Error: connect ECONNREFUSED 127.0.0.1:8545\n    at Object.exports._errnoException (util.js:1022:11)\n    at exports._exceptionWithHostPort (util.js:1045:20)\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)"
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
    at exports.XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:111:32)
    at exports.XMLHttpRequest.dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)

I assume it is due to not running the correct server in the background ECONNREFUSED 127.0.0.1:8545 but the error message should be more clear that this is the case and not just error with invalid JSON RPC response. That is way too cryptic! Cheers!

Ie. catch the error when trying to connect to server and rethrow a more "human" error message!
Thanks :)

I've submitted a fix for this issue in #311.

Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
at XMLHttpRequest.request.onreadystatechange (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:115:32)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpRequestError (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
at ClientRequest. (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:309:9)
at emitOne (events.js:96:13)

The deployer.exec() command is no longer available in Truffle 4.0 due to complexities in implementation. You can get around this by writing a module that accepts the deployer and associated contract abstractions as input to a function, and then importing that module into your migrations.

Closing this ticket for housekeeping. Please open a ticket if you run into any more issues. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tcurdt picture tcurdt  路  3Comments

ferittuncer picture ferittuncer  路  3Comments

rjl493456442 picture rjl493456442  路  4Comments

rotcivegaf picture rotcivegaf  路  3Comments

TOMOAKI12345 picture TOMOAKI12345  路  3Comments