-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Misleading documentation of Truffle configuration #4062
Comments
Hey @barakman! Actually the default network name used by Truffle is "development". The There is probably something else going on for you here. Can you give me very specific steps to take to try and reproduce your error? If you do I'll see if I can reproduce and figure out what is going wrong. |
@eggplantzzz: There you go:
The printout on my env is:
Thank you very much :) |
Ok so I'm actually partly wrong. Truffle looks to see if you have a "development" network defined when you run So this doesn't work exactly like you thought at first but is there some suggestion you could make that you think would make things easier? |
@eggplantzzz: Thanks. So you're saying that:
Well, first of all, I don't quite understand the logical reasoning for this behavior (or let's just say - I cannot quite think of one). Second, as the documentation suggests to declare a This used to be more intuitive in Truffle 4.x, where Ganache was not a part of the Truffle package, and one would need to install it separately. But once Ganache is integrated into the Truffle package, in a way, users are oblivious to it. For example, there's no longer any need to declare it in the Subsequently, I believe that requiring the user to start Ganache manually before My suggestion? Well, as I said above, I cannot think of a good reasoning for So the best IMO would be to revoke this special-case behavior. If you do have a good reasoning for this, and you wish to attain the documentation instructing to use a
So as an alternative to my previous suggestion, assuming that the above works (I haven't tried it TBH), you may want to add that to the documentation. But again, this would require the user to be "aware" of Ganache, and as far as I understand, one of Truffle 5.x goals has been to relieve its users from dealing with Ganache to begin with. Thank you for your help :) |
BTW, the same behavior ( So we have at least two different network names - |
Yes, Truffle always looks for "development". It is meant to be sort of the default configuration. And yes, if it finds it it will try to connect using that configuration. If there is no default, it starts up its own instance. Unfortunately we can't change this behavior at the moment since it would be a breaking change. The docs are pretty accurate in that they say that Truffle will try to connect using the configuration provided. Your configuration above will only work if you run Ganache separately. When you specify a provider like you have, you still need an instance of a network running - the provider only acts as the mechanism that communicates with the network. Maybe the best thing to do is to put a note in the docs explaining the situation with "development" and "test" and how they are "default configurations". What do you think? |
OK, I just realized that in order to get So to begin with, it kinda reduces the "overall confusion" that I had initially found within the documentation. I still think that you may want to mention this in the documentation in some way, so that users will avoid adding that network in their configuration file (as it is probably not needed by the vast majority of them). So to answer the question at the bottom of your message above - yes, I think that it somehow needs to be mentioned (something like - "if you wish to override the network configuration used by Thank you for your help. My initial conjecture about the network name Anyways, glad we've sorted that out, and thanks again for your much appreciated help!!! |
Thanks for the feedback! I know there are still a lot of ways to improve our docs, I'll make a change in the docs to note this behavior. Thanks! |
Issue
The example of how to configure Truffle (in
truffle-config.js
) is misleading.More specifically, the network name used everywhere is
development
(see here).But the default network name for commands such as
truffle test
isproduction
.Subsequently, anyone who follows your configuration example is doomed to get a
Could not connect to your Ethereum client
error. In fact, even specifying the network name explicitly, for example,truffle test --network development
doesn't seem to resolve that. So in short, aproduction
network must be used in the configuration file.I believe that this it is pretty clearly the case in truffle's source code.
Thanks
UPDATE:
TBH, even running
truffle test --network production
when the network name in the configuration file ISproduction
, results with aCould not connect to your Ethereum client
error.Moreover, even declaring a
development
network in addition to theproduction
network (and not instead of it), results with aCould not connect to your Ethereum client
error.So there must be something fundamentally wrong with how you handle of this specific part in the configuration file (or some restriction which is not stated in the official documentation).
The text was updated successfully, but these errors were encountered: