cosmos-sdk: [Bug]: `--home` flag is not respected

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

When running simd, --home flag is not fully respected. The application still creates the config directory under the default home location which is ~/.simapp.

My initial findings show that this line which reads the application flags is called after this line which is used for injecting the sdk’s cli options.

Cosmos SDK Version

0.50.x,main

How to reproduce?

  • Remove the home directory: rm -rf ~/.simapp
  • Start the application by setting the home directory to a non-default location: ./simd start --home ./other-location
  • Check if the default home directory is created: ls ~/.simapp

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 16 (14 by maintainers)

Most upvoted comments

Hey, I wanted to kindly ask what is the ETA on fixing this? We are waiting for this to do an upgrade. We could also help with a PR in case you have other priorities. cc @PoisonPhang

Hi folks, we noticed this issue isn’t working on main still for some cases. For example:

./build/simd version --home ~/.simapp2

Now both ~/.simapp2/ and the default ~/.simapp/ exist. Notably only ~/.simapp2/ has the data directory; both have the config directory.

Are you saying it does not work on v0.50? Only the function EnhanceRootCommand in root.go suffices to call all those functions in client/v2

Turns out this was an issue with how simapp was configured on our fork. Solution is working on v0.50.2 now.

Not yet, and right, and we are a bit holding off on it because the short-term plan is to remove completely client.Context of it. My changes are mainly focusing on getting the keyring to work properly with the flags handler and be able to update it, without breaking the API.

I see, thanks. My solution may prove helpful in the meantime while a much larger refactor is conducted. Though, a few of my changes are genuine fixes. See the description of #18994 for more details.

Tentative solution #18994 I’m not entirely happy with this, but from what I’ve grasped - AutoCLI needs some hefty redesign surrounding how it boot straps itself and supplies context.

IMO, calling WithKeyringDir(ctx.HomeDir) in ReadFromClientConfig feels like a bug.

Hi, first of all I would advise you to work being based off main, as it will complicate your life when opening a PR otherwise.

To answer your question, in v0.50, all modules are using AutoCLI for queries but mostly not for txs. In main all modules have migrated to AutoCLI (queries + txs) unless the UX of a manually defined CLI was better.

Correct, AutoCLI needs some prefilled default data. This will be fixed at the same time as this: https://github.com/cosmos/cosmos-sdk/issues/18122