-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: "NODE_HOME" is not the correct environment variable to get the home path from. #20958
Comments
Yes, I know about this small dispertancy. However as you said at init and before any cobra logic we don't have any flag nor a viper (so we don't know any prefix). What we did in simapp/v2, is set in app.go home on viper to the default folder got by the helper. I'd advise you to do the same on your chain. |
I can try again to update the helper to just use HOME but that still leaves the prefix issue, and I didn't really want to make it a global variable as it makes the UX weird as well. Currently if you don't use the default value nor a flag, you just need to set both env variable |
I guess my sticking point is that |
If you find it okay UX, then let's do it 👍🏾 |
That's only true if you use a prefix. Otherwise, the issue is that you cannot know if you are reading an environment variable or the actual home directory (an issue that existed before too), as they are both called |
Is there an existing issue for this?
What happened?
In
GetNodeHomeDirectory
(inclient/v2/helpers/home.go
), if no--home
flag is provided, it then checks theNODE_HOME
environment variable.However, with viper (and the current simapp setup), the correct environment variable would be just
HOME
, or if the chain uses theSetEnvPrefix
viper functionality (which is used inclient.Context#WithViper
), it will be<prefix>_HOME
.Since
GetNodeHomeDirectory
was written to be called in aninit()
, you can't rely on viper being set up yet. Use of the global viper instance is bad anyway (because any call toviper.New()
will overwrite it). So it'd be better to just provide a mechanism that allows for a different env var to be used, or maybe just a different prefix (e.g.<prefix>_HOME
if provided, or justHOME
if not).Cosmos SDK Version
v0.50.8 and main at
f772a0a2fc
How to reproduce?
I'm not sure what to do to actually demonstrate problems with this, but there will be a discrepancy between the home dirs used for various parts of the app depending on if a
--home
flag is provided, or theHOME
environment variable is set.E.g. In the absence of a
--home
flag, inapp.New
, the home directory is looked up from viper which will use theHOME
env var, but the client config will ultimately be looking at theNODE_HOME
env var and thus will just end up using the default location.The text was updated successfully, but these errors were encountered: