Skip to content

Add RODNEY_HOME env var to support custom state directories.#11

Merged
simonw merged 1 commit into
simonw:mainfrom
senko:peckham
Feb 17, 2026
Merged

Add RODNEY_HOME env var to support custom state directories.#11
simonw merged 1 commit into
simonw:mainfrom
senko:peckham

Conversation

@senko
Copy link
Copy Markdown
Contributor

@senko senko commented Feb 13, 2026

Adds RODNEY_HOME environment variable to customize the state directory, instead of it being hardcoded to ~/.rodney.

This is a potential solution for #6 that could support per-project, or temporary, state directories, while imposing no overhead/impact for users that don't need it.

I choose env variable as the mechanism because there are already some env vars that control how the binary works (ROD_CHROME_BIN, HTTPS_PROXY), and the documented CLI flags (eg. for accessibility testing) seem to be subcommand-specific.

Designed and developed using Claude Code (Opus 4.6), I personally reviewed the output and tested it locally before submitting this PR.

This is the complete plan Claude implemented:


Add RODNEY_HOME environment variable

Context

The rodney data directory (~/.rodney/) is hard-coded via the stateDir() function in main.go:41-44. There is no way to customize it, which blocks per-project or multi-session usage (see GitHub issue #6). We'll add a RODNEY_HOME env var to allow overriding the directory.

Changes

1. rodney-src/main.go (lines 41-44)

Replace the current stateDir() with a minimal version that checks RODNEY_HOME first:

func stateDir() string {
    if dir := os.Getenv("RODNEY_HOME"); dir != "" {
        return dir
    }
    home, _ := os.UserHomeDir()
    return filepath.Join(home, ".rodney")
}

No validation or directory creation here — saveState() (line 63) and cmdStart() (line 262-263) already call os.MkdirAll on the returned path.

2. rodney-src/main_test.go

Add tests (no browser needed — pure function tests):

  • TestStateDir_Default — unset RODNEY_HOME, verify stateDir() returns $HOME/.rodney
  • TestStateDir_EnvVar — set RODNEY_HOME to a temp dir, verify stateDir() returns it

3. rodney-src/help.txt

Add RODNEY_HOME to the configuration/environment section.

4. rodney-src/README.md

Add RODNEY_HOME to the configuration table.

Verification

  1. Run tests: cd rodney-src && go test -run TestStateDir -v
  2. Build: go build -o rodney .
  3. Manual smoke test: RODNEY_HOME=/tmp/rodney-test ./rodney start && ls /tmp/rodney-test/ && RODNEY_HOME=/tmp/rodney-test ./rodney stop

@simonw
Copy link
Copy Markdown
Owner

simonw commented Feb 17, 2026

Thanks for the PR, I've now handled this need in a different way:

@simonw simonw closed this Feb 17, 2026
@simonw
Copy link
Copy Markdown
Owner

simonw commented Feb 17, 2026

I'm open to arguments as to why we should add this as well though, it may turn out to be a useful feature even with --local available.

@simonw
Copy link
Copy Markdown
Owner

simonw commented Feb 17, 2026

I'm leaning towards accepting this - it is a bit messy having a hard-coded path like that for the default case.

@simonw simonw reopened this Feb 17, 2026
@simonw simonw merged commit f49373a into simonw:main Feb 17, 2026
@simonw simonw added the enhancement New feature or request label Feb 17, 2026
@senko
Copy link
Copy Markdown
Contributor Author

senko commented Feb 17, 2026

Thanks for merging! Having both --local and the env var solution seems a bit of an overkill (for my use case either would work), but I can see cases where the combination is useful.

I particularly like your local-first resolution from #14 since this avoids having global state var or prefixing RODNEY_HOME for invocation (which messes up Claude's permission cache which is a bit annoying).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants