Skip to content

fix(cli): respect SUPABASE_HOME across fallback paths#5624

Merged
jgoux merged 3 commits into
supabase:developfrom
ametel01:fix/5214-supabase-home-cache-dir
Jun 24, 2026
Merged

fix(cli): respect SUPABASE_HOME across fallback paths#5624
jgoux merged 3 commits into
supabase:developfrom
ametel01:fix/5214-supabase-home-cache-dir

Conversation

@ametel01

@ametel01 ametel01 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What changed

Routes the global CLI state root through a single SUPABASE_HOME resolver in each language the CLI is written in, so SUPABASE_HOME consistently overrides every machine-global state path instead of being honored on some paths and hard-coded to ~/.supabase on others.

  • Go CLI — new utils.SupabaseHomeDir() helper, used by the access-token, profile, telemetry, and Deno-binary paths. Previously only telemetry state honored SUPABASE_HOME.
  • TypeScript CLI — new pure resolveSupabaseHome(env, homeDir) helper as the single source of truth, used by both the next and legacy shells for the access-token fallback file and the persisted profile file.
  • Docs — auth, telemetry, and login/logout docs now describe the state root as <SUPABASE_HOME or ~/.supabase>.

Why

SUPABASE_HOME is the documented global state root, but several paths bypassed it. Most concretely, the next shell honored SUPABASE_HOME for the access-token file while the Go and legacy shells hard-coded ~/.supabase — so a token or profile written under a custom SUPABASE_HOME by one shell was not found by another. This aligns every path on the documented behavior.

Design notes

SUPABASE_HOME is treated as an application (CLI) concern. The resolver lives only in the two languages the CLI is written in (Go and TypeScript). Libraries stay env-agnostic: @supabase/stack continues to receive its cache root from the CLI as an explicit cacheRoot and never reads SUPABASE_HOME itself, and @supabase/config is project-local and unaffected. This keeps @supabase/stack ergonomic for standalone and test use (an optional cacheRoot with a plain ~/.supabase default).

This keeps a single relocatable home (no separate SUPABASE_CACHEDIR or XDG split), matching the CARGO_HOME precedent referenced in the issue. The access token's primary store is the OS keychain; the SUPABASE_HOME file is only the no-keyring fallback.

Closes #5214.

@ametel01 ametel01 marked this pull request as ready for review June 18, 2026 20:01
@ametel01 ametel01 requested a review from a team as a code owner June 18, 2026 20:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09f5cd36b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/shared/functions/deploy.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2936f1b2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/commands/login/login.e2e.test.ts Outdated
@jgoux jgoux force-pushed the fix/5214-supabase-home-cache-dir branch from 8ee1bde to 2861345 Compare June 24, 2026 15:33
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jgoux jgoux force-pushed the fix/5214-supabase-home-cache-dir branch from 96d2c45 to 7eeaa52 Compare June 24, 2026 15:45
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jgoux jgoux force-pushed the fix/5214-supabase-home-cache-dir branch from 7eeaa52 to dcd6f76 Compare June 24, 2026 15:47
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

jgoux and others added 3 commits June 24, 2026 18:01
Route the Go CLI's global state paths through a single
utils.SupabaseHomeDir() helper so SUPABASE_HOME consistently overrides
the access-token, profile, telemetry, and Deno-binary locations instead
of being honored only by telemetry state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a pure resolveSupabaseHome(env, homeDir) helper as the single TS
source of truth for the SUPABASE_HOME contract (trimmed, non-empty, else
<homeDir>/.supabase). The next and legacy shells both resolve through it
for the access-token fallback, persisted profile, and telemetry-state
paths, so state written under SUPABASE_HOME in one shell is found by the
other.

Libraries stay env-agnostic: the CLI owns SUPABASE_HOME and threads the
resolved path to @supabase/stack as cacheRoot rather than the library
reading the env var itself.

Update the legacy login/logout e2e tests, which asserted the old
hard-coded ~/.supabase path; the e2e harness sets SUPABASE_HOME, so the
token now lands at <SUPABASE_HOME>/access-token.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Update auth, telemetry, and login/logout docs to describe the global
state root as <SUPABASE_HOME or ~/.supabase> instead of hard-coding
~/.supabase, and note the legacy Go Deno binary path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jgoux jgoux force-pushed the fix/5214-supabase-home-cache-dir branch from dcd6f76 to 0bc5569 Compare June 24, 2026 16:01
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jgoux jgoux added this pull request to the merge queue Jun 24, 2026
Merged via the queue into supabase:develop with commit 4bb2574 Jun 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to configure cache directory

2 participants