2

I just spent a fair amount of time scratching my head trying to figure out why my truffle migration wasn't doing anything when trying to deploy to the TestRPC client. It just kept saying "using network testrpc" without any subsequent status messages. I tried running compile again, several times over the debugging session, and there were no errors.

I then did a migration with the "--reset" flag and discovered that a new smart contract file I added wasn't being found during migration ("is not defined". Still working on that since the code and contract are there).

To save time in the future, is there any harm in always including the --reset flag when doing a Truffle compile and migrate, at least when using the TestRPC client?

What are the downsides of the using the "--reset" flag in time or gas when performing a migration on the main net, and in time on the test net (assuming there are any)?

Does the "--reset" flag cause compiles to be slower in a manner similar to "cleaning" a C++ project, which triggers the need to recompile all the source files to object files again? With migrations, does it trigger the need to "republish" all the smart contract code to the deployment network instead of just the changed smart contracts (i.e. - just the differential)?

3

The --reset flag will force to run all your migrations scripts again. Compiling if some of the contracts have changed. You have to pay gas for the whole migration again. For ganache/testrpc it should not be an issue it is just a extra delay. But for deploying against a public network: mainnet, rinkeby, ropsten, etc. it can be really annoying to have to wait that for tiny changes.

The --all flag will force to recompile all your contracts. Even if they didn't change. It is more time compiling all your contracts, and after that it will have to run all your deploying scripts again.

I found that truffle sometimes will fail to acknowledge a contract was modified and will not compile it again, not run the deploy scripts. Even with both flags --all and --reset it will not work. If everything fails you can delete the build/ directory. This will force a recompilation of all your contracts and running all your deploy scripts again.

  • Thanks. I guess some things never change. That's the same set of procedures, each progressively more extreme, you have to do with nearly all languages with a compile step when things "just don't seem right". – Robert Oschler Mar 14 '18 at 6:13

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.