I have an initial folder with an extension of the tutorial, and I'm now working in a new folder:

new-project
 |
 +- build
 +- contracts
 |         +- NewContract.sol
 |
 +- migrations
 +- ...

truffle-test
 |
 +-pet-shop-tutorial
 +-old-project
 |         +- build
 |         +- contracts
 |                   +- oldContract.sol

I made the new_project as a copy of old-project, but now when I'm in the new-project folder and I run truffle compile or truffle migrate what I see is:

Compiling .\..\truffle-test\old-project\contracts\OldContract.sol...
Writing artifacts to .\build\contracts
[...]

And truffle actually writes the artifacts of the old contract in the new folder!

I'm left with this:

new-project
 |
 +- build
 |         +- OldContract.JSON
 |         +- NewContract.JSON
 +- contracts
 |         +- NewContract.sol

And the new contract doesn't seem to be deployed. I edited 1_initial_migration.js to mention the new contract, and it's still not deployed.

What should I do? Did I forget something? How do I prevent truffle from compiling from other folders?

  • 1
    never experienced this issue but you might try to initialize your folder using truffle init. If you need some contracts or file from the old project just copy it – mirg Mar 19 at 10:28
  • Have you tried focussing on the new map when migrating for instance? truffle migrate ./folder/file – Gabe Mar 19 at 11:50
  • 1
    try deleting your build folder, then rerunning 'truffle migrate'. Also make sure that you changed the name of your contract in the solidity file (Contract name matches file name) – thefett Mar 19 at 13:31
up vote 0 down vote accepted

As thefett suggested, it worked to delete the build folder.

My guess is that the Migration contract was already built but with wrong information, and because the JSON existed truffle compile didn't replace it.

When the folder was cleared, the compilation build the correct JSONs and the deployment went as expected.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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