-
Notifications
You must be signed in to change notification settings - Fork 677
Description
What happened?
The osmosisd init
command has a hardcoded behavior that always tries to create a .env
file in ~/.osmosisd
(the DefaultNodeHome
), even when a different home directory is specified with the --home
flag. This causes initialization to fail in containerized environments with read-only root filesystems.
Current Behavior
When running osmosisd init
with a custom home directory:
osmosisd init mynode --home /custom/path
The init process:
- Correctly uses
/custom/path
for most initialization - BUT still tries to create
/home/user/.osmosisd/.env
due to theCreateEnvFile
function
Expected Behavior
The CreateEnvFile
function should respect the --home
flag and create the .env
file in the specified home directory, not in the hardcoded DefaultNodeHome
.
Root Cause
In cmd/osmosisd/cmd/init.go
, the CreateEnvFile
function (lines 247-282) uses app.DefaultNodeHome
which is hardcoded to ~/.osmosisd
:
func CreateEnvFile(cmd *cobra.Command) error {
// Check if .env file was created in /.osmosisd
envPath := filepath.Join(app.DefaultNodeHome, ".env") // <-- This ignores --home flag
// ...
}
Impact
This issue prevents Osmosis from running in:
- Kubernetes environments using operators (like cosmos-operator)
- Containers with read-only root filesystems
- Any environment where the default home directory is not writable
Proposed Solution
The CreateEnvFile
function should use the home directory from the command context instead of the hardcoded DefaultNodeHome
:
func CreateEnvFile(cmd *cobra.Command) error {
clientCtx := client.GetClientContextFromCmd(cmd)
envPath := filepath.Join(clientCtx.HomeDir, ".env") // Use the actual home dir
// ...
}
Workaround
Currently, operators must create a writable volume at ~/.osmosisd
just for the init process, even though all actual chain data is stored elsewhere.
Environment
- Osmosis version: v29.0.0 (still present in latest)
- OS: Linux containers
- Context: Running in Kubernetes with cosmos-operator
Additional Context
Other Cosmos SDK chains (Cosmos Hub, Noble, Penumbra, etc.) don't have this issue because they don't have this CreateEnvFile
function that writes to a hardcoded location.
Osmosis Version
v29.0.0
How to reproduce?
osmosisd init mynode --home /custom/path
you will see it will try to write data outside of --home
Metadata
Metadata
Assignees
Labels
Type
Projects
Status