Compile Error #3798
Comments
I also have the same problem |
Downgrade truffle to: 5.1.65 |
Yes downgrading to 5.1.65 works. Thanks a lot! |
Thank you sooooo much!😀 |
Thank you for this solution but why did you close the issue? it seems like if downgrading to a older version is the fix then it should still be open because it's still broken in 5.1.66 which is what new people will install by default |
I'm having a similar issue. The initial build of my contracts works fine (when artifacts folder is empty). However, every subsequent time I try to
I'm attempting to build with |
Same problem here |
We had the same issue, commenting here to track progress. |
have you found any solution to this? |
I have been getting the same error and found 2 solutions. First is to use a older solidity version (it works for me with 0.6.6) or to use a different tool then truffle (like hardhat) |
I tried with Truffle v5.1.65 (core: 5.1.65) and Solc 0.6.6, but nothing works🤯 |
for me I had to delete truffle globally, delete node_modules in my project and then after reinstalling everything it worked |
downgrading to 5.1.65 worked for me. curious to know why 5.1.66 didn't work |
This works |
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
develop: {
port: 8545
}
},
compilers: { //I added this parameter.
solc: {
version: "0.5.16"
}
}
};
|
Downgrading to truffle@5.1.65 worked for me. |
@jha-prateek answer of using "truffle compile --all" worked for me. It seems most are making changes or adding new contracts and forgetting to recompile |
OK, it seems a lot of people are having this problem. Does anyone have a reproduction example we could check out? Otherwise I'll attemtp to reproduce this myself, but I'm hoping someone has an example I can use directly. Thank you! |
I have a suspicion that PR #3802 might fix this problem. However, I really need a reproduction example to be able to check... |
Try to delete your build folder, it worked for me. |
Reproduction:
In one terminal:
In another terminal:
Results in this error:
Downgrading to 5.1.65 and the error goes away and tests run successfully. I'm on Node 10.23.0, if it matters. |
@ehildenb Thanks! I'll check it out. |
Hm, I can't seem to reproduce this at the moment. I'll have to try some more combinations later, I guess. That said, I have a suspicion that #3802 might fix this anyway... |
Yes, but it's strange because |
Can you check, how |
Ah, good point. I'd been compiling from scratch. But, the example given by @ehildenb above also involves compiling from scratch. So that doesn't help. Does anyone have a more specific reproduction example I could try, including which contracts to compile in what order? |
Cool, It's work for me :) |
I am still hitting the same error after attempt with Truffle 5.1.66 and solc 0.8.0. I tried downgrading truffle to 5.1.65 and using Node 10.23.0, it returns me the same error. I tried with the latest truffle version seems like the issue still persists. TypeError: Cannot read property 'imports' of undefined Let me know if I can be of any help. |
have you try deleting build folder? |
Yup. I deleted and recompile the folder and test it each time I use a different version.. but hit into this error (with different version denote below) when i run truffle test... anyone hit the same issue as per mine? |
@lawrenceCP Are you still getting the error with Truffle 5.3.0? Could you confirm that? Thank you! @Soohan-Park To be clear, deleting the build folder (or just using |
@haltman-at yes, after tried delete the build folder (or run truffle compile --all) then run truffle test. I am still hitting the error with Truffle 5.3.0. TypeError: Cannot read property 'imports' of undefined Which node version is the recommended version? |
@lawrenceCP OK, do you have some sort of reproduction example I could check out to figure out what's going on? Thanks! (I'll reopen the issue.) We currently support Node 10, Node 12, and Node 14, although we may be dropping support for Node 10 in a few months. |
@haltman-at lets try this:
Then you should be able to get an error similar to this. TypeError: Cannot read property 'imports' of undefined |
To provide another data point here, @lawrenceCP I cloned your repo and had to fix a couple of imports. In Is it possible that you have other files in your repo that are not being committed or something? If you do a fresh clone and complete the steps you listed do you still get the error? |
@eggplantzzz Thanks for the tips. After changing the import statement from import "truffle/Deployment.sol to import "truffle/DeployedAddresses.sol" as well as the Assert.equal statement, I managed to run truffle test without errors. @haltman-at may proceed to close off this issue. Thanks. |
@eggplantzzz I don't think that resolves this issue. Truffle shoud not produce errors, regardless of whether their imports are correct or not. If they have incorrect imports, they should see a compile error, not a Truffle error! |
FYI. I'm stil seeing the issue, but it's happening less than before, and
seems to go away if I delete the build directory.
…On Fri, Apr 9, 2021 at 4:18 AM Harry Altman ***@***.***> wrote:
@eggplantzzz <https://github.com/eggplantzzz> I don't think that resolves
this issue. Truffle shoud not produce errors, regardless of whether their
imports are correct or not. If they have incorrect imports, they should see
a compile error, not a Truffle error!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3798 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWGAGPJBCJNJTZHYAJQ6ODTHYFRFANCNFSM4XRIBBLA>
.
|
@haltman-at I didn't say it solves the original issue by the original poster. I am merely saying that after correcting the errors I listed, I am able to run |
I got this same error for a seemingly unrelated problem: I was missing a } in the newest contract I had just added deleted /build realized/fixed the mistake |
I had this error too, got the undefined imports message only when running "truffle test" but not "truffle compile".
The version of solidity didn't seem to matter, got it to work with 0.5.16 and >=0.8.0 |
@lawrenceCP OK, I have successfully reproduced the error! Thanks so much for the example, sorry for taking so long to get back to this; I've had my hands pretty full. But now I can look into what's causing this and hopefully fix it. |
This is still broken on the latest version and 0.5.15. Getting truffle to work with solc has just been painful. |
@gideongrinberg A fix for this (or what should be a fix for this) will go out with this week's release! |
@haltman-at is there any temporary fix? |
Well, as other commenters have mentioned, the error doesn't occur when recompiling the whole project. But, if you can wait just a few hours a proper fix should go out in today's release, as mentioned, so any temporary workaround will be quite temporary indeed. :) |
The fix for this should be out now, so I'm closing this once again. If anyone sees this again, please let us know and we'll reopen it a third time. |
Hey, I am getting this error even with most recent version of truffle ...
I tried multiple solutions provided in this thread (downgrading and changing solc version, and truffle compile --all), but none of them worked. |
@haltman-at can you please re-open this issue |
@sjschweber You're describing an different issue; this issue is about an undefined reference crash, not about being unable to compile due to pragma mismatch. If you are having an issue with pragma mismatch, you might want to file a new issue for that, but I'd suggest that rather than file an issue for that you might want to start with talking to our support team to make sure this is an actual bug. Thanks! |
I wanted to try out Truffle/Ganache. So I followed
https://ethereum.org/en/developers/tutorials/create-and-deploy-a-defi-app/
-I am having version issues with Truffle. This is what "truffle version" shows:
Truffle v5.1.66 (core: 5.1.66)
Solidity - 0.7.4 (solc-js)
Node v15.5.1
Web3.js v1.2.9
I specified solc 0.7.4 in truffle-config.js because the openzeppelin that I use asks for pragma between 0.6 and 0.8.
I specified "pragma solidity >=0.4.22 <0.9.0;" in my contracts. But when I do "truffle compile", I got this:
Compiling your contracts...
✔ Fetching solc version list from solc-bin. Attempt #1
✔ Downloading compiler. Attempt #1.
TypeError: Cannot read property 'imports' of undefined
at Object. (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/requiredSources.js:98:1)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/requiredSources.js:5:42)
Truffle v5.1.66 (core: 5.1.66)
Node v15.5.1
Seems like I am not able to make truffle, solidity, and openzeppelin all happy wrt versions.
The text was updated successfully, but these errors were encountered: