Is there an existing issue for this?
What happened?
In GetNodeHomeDirectory (in client/v2/helpers/home.go), if no --home flag is provided, it then checks the NODE_HOME environment variable.
However, with viper (and the current simapp setup), the correct environment variable would be just HOME, or if the chain uses the SetEnvPrefix viper functionality (which is used in client.Context#WithViper), it will be <prefix>_HOME.
Since GetNodeHomeDirectory was written to be called in an init(), you can't rely on viper being set up yet. Use of the global viper instance is bad anyway (because any call to viper.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 just HOME 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 the HOME environment variable is set.
E.g. In the absence of a --home flag, in app.New, the home directory is looked up from viper which will use the HOME env var, but the client config will ultimately be looking at the NODE_HOME env var and thus will just end up using the default location.
Is there an existing issue for this?
What happened?
In
GetNodeHomeDirectory(inclient/v2/helpers/home.go), if no--homeflag is provided, it then checks theNODE_HOMEenvironment variable.However, with viper (and the current simapp setup), the correct environment variable would be just
HOME, or if the chain uses theSetEnvPrefixviper functionality (which is used inclient.Context#WithViper), it will be<prefix>_HOME.Since
GetNodeHomeDirectorywas 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>_HOMEif provided, or justHOMEif not).Cosmos SDK Version
v0.50.8 and main at
f772a0a2fcHow 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
--homeflag is provided, or theHOMEenvironment variable is set.E.g. In the absence of a
--homeflag, inapp.New, the home directory is looked up from viper which will use theHOMEenv var, but the client config will ultimately be looking at theNODE_HOMEenv var and thus will just end up using the default location.