-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Mismatch in default networks #1726
Comments
Offering solution A from trufflesuite/truffle#1726
Thanks for this thorough write-up, and for including potential solutions! Certainly makes our jobs easier. We will review this and come up with next steps from our perspective and discuss them here. |
I still get the same error when I try to test my contracts. is there any solution. Please Help !!! |
@lundrimazemi Uncomment the contents of truffle-config.js, as in the commit above. |
/**
*/ // const HDWalletProvider = require('truffle-hdwallet-provider'); /**
networks: {
}, // Set default mocha options here, use special reporters etc. // Configure your compilers |
still it is not working, or i should uncomment something else |
Try following the exact steps in the original post above, except uncomment the contents of truffle-config.js between steps 6 and 7. Just before you start step 7, the config file should match this. |
Thank you sir @wbt |
Hello I am a noob and hit this wall when I was trying truffle migrate. Thanks for OP and this page for solving this problem for me, and that has wasted quite a bit of time. |
@gnidan How have those closed-door discussions gone? Can we implement one of the proposed solutions, as people are getting confused (probably including many who can't find this particular page and the fork with a solution)? |
Does the |
@eggplantzzz I'm not on the latest version at the moment due to blockers like #1942, which apparently will not be addressed anytime soon. However, looking at the newbies coming in and experiencing the problem, it appears to still be a problem. There are very detailed reproduction steps above which could be tried with different versions, starting with the reported one. There is also no specific reason to believe this is fixed absent any pointer to a change in the code. So I suspect this issue with the code still exists, in addition to the issue with the unreported closed-door discussions leaving users in the dark. |
This is a really bad "getting started" user experience, that I hit also. If Ethereum wants to hit Joe's 1 million developers goal, this type of UX won't do. It sends the massage to developers that the tools aren't ready yet. |
Thanks @wbt . |
I found a workaround on top of @lundrimazemi 's solution. After adding ganache to the network config run the command
|
I think this issue might not be a problem anymore; since Can anyone confirm? Thanks! |
Closing this for issue maintenance. If anyone discovers that this problem still exists, please do let us know! Thanks all! |
I am facing an issue. I have set this in th etruffle-config.js However, for any function of truffle I try to run : (truffle migrate, truffle develop, truffle test --network) I keep getting errors that says my host and port are not the same. Error (for truffle migrate -reset): Error (for truffle test --network ganache) |
Issue
Default networks mismatch in a way likely to confuse newcomers.
Steps to Reproduce
npm uninstall truffle -g
npm install truffle -g
(this and the previous ensures running the most current version, now 5.0.4)mkdir metacoin
cd metacoin
truffle unbox metacoin
truffle compile
truffle migrate
truffle test
Expected Behavior
The expected behavior is that the three listed and suggested commands, which "unbox" indicates are ready, should actually be runnable without error.
If
truffle migrate
uses Ganache automatically, without error, I would expecttruffle test
to do the same.To get this to work as documented, you have to first manually uncomment the content of truffle-config.js.
If you skip step 1 ("Start Ganache"), step 8 (
truffle migrate
) has the following error:Actual Results
You cannot run the three suggested commands out of the box. If Ganache is started, you'll get an error at the
truffle test
stage because network configuration information is being pulled from different places, unintuitively. If Ganche is not started, you'll get an error at thetruffle migrate
stage.The error message reports a mismatch of two network ID numbers, neither of which come from code in the user's project, a confusing and frustrating introduction to the technology. The error does not do a good job of helping the user figure out what the problem is and/or how to fix it (e.g. uncomment truffle-config.js default values).
Potential Solutions
A. One possible fix that might come to mind is to just uncomment the Ganache configuration details by default, instead of requiring the user do the manual workaround. This is easy. However, that is not allowed per requirement here, explained as being on the basis that "we want the boxes to work out of the box for testing." However, the boxes do not work "out of the box" for testing. Commenting out that default configuration makes it harder when somebody has a client running, and does not make it easier when they don't.
B. The
migrate
step appears to take default network information from truffle/packages/truffle-core/lib/environment.js lines 22-33. Thetest
step could use the same logic and draw on the same defaults.C. We could intentionally decide that we do not want example projects to work "out of the box" and remove the default from
environment.js
, replacing it with a more helpful error message with instructions to add or uncomment a network configuration in truffle-config.js, instead of a confusing error message about a network id mismatch.D. Other options?
The issue is filed against this project because option A was discussed and ruled out in the box-specific project, and options B and C affect code in this project.
Environment
truffle version
): v5.0.4node --version
): v9.3.0npm --version
): v6.8.0The text was updated successfully, but these errors were encountered: