Truffle: Error: Could not find artifacts for " + import_path + " from any sources

Created on 17 Apr 2018  路  11Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

truffle(develop)> migrate --reset
Compiling .contractsMetaCoin.sol...
Writing artifacts to .buildcontracts

Using network 'develop'.

Running migration: 1_initial_migration.js
Replacing Migrations...
... 0xbe08a360a53514f1751645230046ad03034f2ce3fc6ae2591ecfd34069c67e6a
Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
... 0xd7bc86d31bee32fa3988f1c1eabce403a1b5d570340a3a9cdba53a472ee8c956
Saving artifacts...
Running migration: 2_deploy_contracts.js
C:UserslaboAppDataRoamingnpmnode_modulestrufflebuildcli.bundled.js:66536
throw new Error("Could not find artifacts for " + import_path + " from any sources");
^

Error: Could not find artifacts for ./MetaCoin.sol from any sources
at Resolver.require (C:UserslaboAppDataRoamingnpmnode_modulestrufflebuildcli.bundled.js:66536:9)
at Object.require (C:UserslaboAppDataRoamingnpmnode_modulestrufflebuildcli.bundled.js:77630:36)
at ResolverIntercept.require (C:UserslaboAppDataRoamingnpmnode_modulestrufflebuildcli.bundled.js:239478:32)

at C:\Windows\system32\metacoin\migrations\2_deploy_contracts.js:2:26
at Script.runInContext (vm.js:74:29)
at Script.runInNewContext (vm.js:80:15)
at C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:125917:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:532:3)

Environment

  • Operating System: Windows

  • Truffle version (truffle version): truffle v 4.1.3

  • node version (node --version):v9.9.0
  • npm version (npm --version): v 5.8.0

Most helpful comment

Make sure you have the Migrations.sol and that the name of the contract is the same as the name of the file, that solved the issue for me.

All 11 comments

@vidhyaramani Could you try upgrading to the latest version 0.4.16? We had an import path resolution bug on Windows and it's fixed in the newest patch release.

No i have tried to upgrade it now its 0.4.6. Can you please give me the upgrade comments for windows?

Thanks in advance!

@vidhyaramani Apologies - there's a typo in my comment. The latest version is 4.1.6 and you should be able to install it with:

npm install -g truffle

Windows specific installation instructions can be found here

truffle(develop)> migrate
Compiling .\contracts\MetaCoin.sol...
Compilation warnings encountered:
/C/Windows/system32/metacoin/contracts/MetaCoin.sol:6:2: Warning: No visibility specified. Defaulting to "public".
function helloWorld()returns (string){
^ (Relevant source part starts here and spans across multiple lines).
,/C/Windows/system32/metacoin/contracts/MetaCoin.sol:6:2: Warning: Function state mutability can be restricted to pure
function helloWorld()returns (string){
^ (Relevant source part starts here and spans across multiple lines).
Writing artifacts to .\build\contracts
Using network 'develop'.
Error: Attempting to run transaction which calls a contract function, but recipient address 0x345ca3e014aaf5dca488057592
ee47305d9b3e10 is not a contract address
at Object.InvalidResponse (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\err
ors.js:38:1)
at C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
at C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\
~\web3\lib\web3\httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\
xhr2\lib\xhr2.js:64:1)
at XMLHttpRequest._setReadyState (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\x
hr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\l
ib\xhr2.js:509:1)
at IncomingMessage. (C:\Users\labo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr
2.js:469:1)
at IncomingMessage.emit (events.js:185:15)
at IncomingMessage.emit (domain.js:439:23)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:114:19)

pragma solidity ^0.4.18;

contract Metacoin{

function helloWorld()returns (string){
    return 'helloWorld';
}

 }

truffle: 0.4.6

please explain how to solve this? Thanks!

@vidhyaramani I'm going to close this issue since your initial problem seems to be resolve with an upgrade. It looks like you've begun experimenting with the MetaCoin contract - this is a good place to start. I would recommend using the unit tests feature truffle test - and writing your tests in javascript - to get a sense of how compilation works, how to make calls to contracts etc. There are also a lot of great truffle tutorials online and at our website, in addition to documentation.

Make sure you have the Migrations.sol and that the name of the contract is the same as the name of the file, that solved the issue for me.

@alacret that took away the previous error but now I getting a new error when running tests.
Error: invalid bytes32 value (arg="trackHash", coderType="bytes32", value=1)
although my test were previously running fine

Make sure you have the Migrations.sol and that the name of the contract is the same as the name of the file, that solved the issue for me.

Worked for me. For those who had the error for your contract and function having the same name just add "Fuc" or "Function" onto the end of your function name and keep everything else the same.

Make sure you have the Migrations.sol and that the name of the contract is the same as the name of the file, that solved the issue for me.

I should feel that I explain the solution. 'truffle init' make folders (and sample files). The folders include the 'contracts' folder. The 'contracts' folder must consist of sol program files (for example. MetaCoin.sol). Sol program has been written with a solidity programming language.

I was having the same issue and it came down to the MyContract.sol file being in the main project directory instead of the ../contracts/ directory. Also ensure that you have a constructor in your contract that initializes the code you're trying to run.

As @pianchemist said, truffle init turns the folder in which you run the command into the staging directory for your project and sets up standard default files and structure. The creation of files after this and placing them in the correct directories are up to you. For simple projects, having your contract within the contracts directory is as complex as it needs to be. For larger projects, it works like any other programming structure: you may have a folder that contains library code, or a hierarchy of contracts depending on the complexity of your project.

Regardless of size and complexity, ensure that your config is pointing to the correct locations using the staging directory as the root of the project. Ensure that any import statements also point to the correct location.

Was this page helpful?
0 / 5 - 0 ratings