Skip to content

[Bug]: "NODE_HOME" is not the correct environment variable to get the home path from. #20958

@SpicyLemon

Description

@SpicyLemon

Is there an existing issue for this?

  • I have searched the existing issues

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
🥳 Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions