Closed chapati23 closed 5 years ago
I'm having the same issue :/
I've tried to play with working_directory
and migrations_directory
in truffle.js too but no luck.
Migration fails on this line:
var Migrations = artifacts.require("./Migrations.sol");
error for me:
$ truffle migrate
Using network 'development'.
Running migration: 1_initial_migration.js
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:49085
throw new Error("Could not find artifacts for " + import_path + " from any sources");
^
Error: Could not find artifacts for ./Migrations.sol from any sources
at Resolver.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:49085:9)
at Object.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:72130:36)
at ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:228716:32)
at /Users/petro/ether/ucd-poc/migrations/1_initial_migration.js:1:28
at ContextifyScript.Script.runInContext (vm.js:53:29)
at ContextifyScript.Script.runInNewContext (vm.js:59:15)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:99900:14
at tryToString (fs.js:512:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:500:12)
When look to
ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:228716:32)
there is a simple line:
// Note, will error if nothing is found.
var resolved = this.resolver.require(import_path);
There I gave up tracing which module called with what import_path
value :/
In my case, I had mistake in contract name. Contract name should same name as the .sol file name.
@DmitryRomaniuk : do you mean it works for you with a custom build folder?
btw my workaround currently is leaving the original folder structure in place and creating symlinks => works well so far
Sent from my iPhone
On Aug 14, 2017, at 08:59, Peter Petrovics notifications@github.com wrote:
@DmitryRomaniuk : do you mean it works for you with a custom build folder?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
unfortunately symlinks aren't trivial for us b/c of mixed windows and linux dev environments :/
yeah it's a hack. should definitely be fixed in truffle
here's our latest workaround, now without symlinks so should work across systems @szerintedmi
// package.json
{
…
// Compile smart contracts and copy output into src/ and build/ folders
"build:contracts": "truffle compile && yarn contracts:sync-src",
// Workaround to use custom build directories until this issue gets resolved: https://github.com/trufflesuite/truffle-migrate/issues/10
"contracts:sync-src": "rimraf src/contracts && cp -R build/contracts/ src/contracts",
…
}
I got the error because I had explicitly stated the contract build directory in my truffle.js file with `contracts_build_directory: "./build",
, even though it uses the build/
directory by default anyway:
module.exports = {
contracts_build_directory: "build",
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
}
}
};
After I removed that line of code so it became the following, the error message went away.
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
}
}
};
Was on a windows machine and ran into some problems, below is a changed sync-src script command for windows.
Based on workaround posted by @chapati23
"contracts:sync-src": "rimraf src\\contracts\\* && xcopy build\\contracts src\\contracts /F /Y"
ps: assumes that src/contracts folder exists.
I can experience the issue as well. contracts_build_directory
is broken basically. makes me think truffle deploy
must have hardcoded a lookup into build folder or don't even read that option
Experiencing this as well. The problem happens when setting either contracts_build_directory
or build_directory
. What's weirder is even when you set it them to the default values:
build_directory: "build",
contracts_build_directory: "build/contracts",
The error still happens.
having the same issue when setting contracts_build_directory
I got the same problem just now, but I solved it in this way.
After your compilation, go to your_folder_location\build\contracts
folder.
Then you will see a JSON file which not related to your contract file.
Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name )
But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.
That's it.
I have some workaround for this case. The solution is you have to use fullpath for the build directory in truffle.js.
// truffle.js
const fullPathBuildDirectory = `${__dirname}/src/build/contracts`;
module.exports = {
contracts_build_directory: fullPathBuildDirectory,
networks: {
...
}
};
something like this will solve the issue.
Has this issue been open for a year without a solution?
Truffle has a lot of problems.GIVE UP.
The solution from @qapquiz above solved it for me! https://github.com/trufflesuite/truffle-migrate/issues/10#issuecomment-402441008
It looks like as if you need to keep (a copy of) Migrations.json in build/contracts, otherwise you will get an an error like
Error: Attempting to run transaction which calls a contract function, but recipient address 0x8cdaf0cd259887258bc13a92c0a6da92698644c0 is not a contract address
But as Migrations.sol / Migrations.json normally never change, this is just a one time action during project setup and thus should not be too much of an issue.
Thanks for raising this issue @chapati23!
We've finally merged a fix for this into truffle@next via #1331.
Description
I need a custom build directory so I set
contracts_build_directory
tosrc/contracts
in thetruffle.js
config file. This worked fine fortruffle compile
=> my compiled contracts ended up insrc/contracts
as expected.Error
However when I tried running
truffle migrate
it failed with the following error:Question
Anything else I need to configure when changing the
contracts_build_directory
that I'm overlooking? Stabbing a bit in the dark here as the custom-build options aren't very well documented yet.