Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): put ~/.local/bin on the boot service PATH so providers resolve #5013

Closedarhxam(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/5013/headopened View on GitHub

What Changed

The generated systemd user unit (renderBootServiceUnit) now sets an explicit Environment=PATH= that prepends ~/.local/bin and ~/bin (via the %h specifier) to the standard system directories.

File: apps/server/src/cloud/bootService.ts, plus the byte-for-byte render test.

Why

Closes #4913.

The unit set no PATH, so t3code.service inherited the systemd user manager's minimal environment, which does not include ~/.local/bin — exactly where user-scoped provider CLIs (claude, codex) land on a headless install. Ubuntu's ~/.profile prepends ~/.local/bin, but that only runs for login shells and a systemd user unit never sources it. The result: a server that listens, pairs and authenticates but exposes zero providers, so no thread can run. It is also confusing to diagnose, because t3 serve run by hand over an SSH login shell finds every provider while the service cannot.

%h expands to the home dir (the same specifier the unit already uses for WorkingDirectory), and directories absent on a given distro are simply skipped during lookup. renderBootServiceUnit stays pure and deterministic, so status still flags an older unit as out-of-date and offers a repair that rewrites it with the PATH.

Verified: bootService.test.ts passes (render test updated byte-for-byte); apps/server typecheck is clean.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

Note

Low Risk Scoped to generated systemd unit environment and test expectations; no auth, data, or runtime logic changes beyond PATH for CLI discovery.

Overview The generated systemd user unit for t3code.service now sets an explicit Environment=PATH= that prepends %h/.local/bin and %h/bin ahead of the usual system directories, matching what login shells get from ~/.profile on typical Ubuntu headless installs.

Why it matters: without this, t3 serve under the user manager inherited a minimal PATH and could not find user-scoped provider CLIs (e.g. claude, codex) in ~/.local/bin, so the service listened and paired but exposed zero providers—while the same command over SSH looked fine.

renderBootServiceUnit stays deterministic, so status still compares the installed unit byte-for-byte; units written before this change are reported out of date and repair/install rewrites them with the new PATH. Tests assert the full rendered unit and PATH prefix.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit bba10621ae5f5dd2131fd7314e3ffd8f92830196. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add ~/.local/bin to PATH in generated systemd boot service unit

The BootService.renderBootServiceUnit function now injects an Environment=PATH= line into the [Service] section, prepending %h/.local/bin and %h/bin before standard system directories. This ensures user-installed binaries (e.g. provider CLIs) are resolvable when the boot service starts. Behavioral Change: the boot service process now runs with an explicit PATH instead of inheriting the default systemd user environment.

📊 Macroscope summarized bba1062. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 8e322a42-42e7-48e1-bae7-25b20bef0d49

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -100,3 +100,12 @@
      100100 "[Service]",
      101101 "Type=simple",
      102102 "WorkingDirectory=%h",
      103+ // A systemd user unit inherits the user manager's minimal PATH, which does
      104+ // NOT include ~/.local/bin — the directory Ubuntu's ~/.profile prepends and
      105+ // where user-scoped provider CLIs (claude, codex) land on a headless
      106+ // install. Without this, `t3 serve` finds every provider by hand from a
      107+ // login shell but the service starts with zero providers. Prepend the
      108+ // user-local bins to the standard system PATH; %h expands to the home dir
      109+ // (like WorkingDirectory), and absent entries (e.g. /snap/bin on non-Debian
      110+ // distros) are simply skipped during lookup.
      111+ "Environment=PATH=%h/.local/bin:%h/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High cloud/bootService.ts:111

      The new Environment=PATH=... directive unconditionally replaces the user manager's inherited PATH rather than prepending to it. Any provider CLI installed in a location not in this hard-coded list (e.g. ~/.npm-global/bin, an nvm directory, or a path set via environment.d) becomes undiscoverable after install, regressing a previously working provider setup to zero providers. Consider using ${PATH} to preserve existing entries: Environment=PATH=%h/.local/bin:%h/bin:...:${PATH}.

      Suggested change
      111- "Environment=PATH=%h/.local/bin:%h/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      111+ "Environment=PATH=%h/.local/bin:%h/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:${PATH}",
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/cloud/bootService.ts around line 111:
      
      The new `Environment=PATH=...` directive unconditionally **replaces** the user manager's inherited `PATH` rather than prepending to it. Any provider CLI installed in a location not in this hard-coded list (e.g. `~/.npm-global/bin`, an nvm directory, or a path set via `environment.d`) becomes undiscoverable after install, regressing a previously working provider setup to zero providers. Consider using `${PATH}` to preserve existing entries: `Environment=PATH=%h/.local/bin:%h/bin:...:${PATH}`.
    4. Approvability

      Verdict: Needs human review

      1 blocking correctness issue found. An unresolved high-severity review comment identifies that the hardcoded PATH replacement could regress previously working provider setups by not preserving the inherited PATH. This potential bug should be addressed before merging.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. t3dotgg(GitHub profile, opens in a new tab) added labelsvouch:trusted

    6. t3dotgg(GitHub profile, opens in a new tab) removed labelsvouch:unvouched

    7. Note: GPT-6 on behalf of shivam (@shivamhwp).

      The fixed PATH replaces the systemd user manager's PATH, so provider directories supplied through environment.d or import-environment can disappear. For example, a tool installed only in /opt/company/bin is retained by the current login-shell PATH merge but is lost with this unit when no shell profile adds it back. Preserve inherited entries when adding user-local directories.

      The server already calls fixPath() before startup and merges the login shell PATH with the inherited PATH. The missing directory in /proc/<pid>/environ alone does not establish the provider lookup failure. Please pin down the failed hydration or lookup path before choosing the fallback, and rebase onto the current service launcher implementation.

    8. juliusmarmingecommented

      Note

      This comment is posted by Julius' dot

      Triage of bba1062 is pending a causal explanation under establishing the problem and verification.

      The service failure in #4913 is useful, but the assessed source already has fixPath() merging the login-shell PATH with the inherited PATH. The later reports in #4913 specifically concern cloudflared resolution, while this PR describes Claude/Codex provider discovery. The updated byte-for-byte unit-render test proves the emitted line, but does not distinguish these failure paths.

      Could the author identify which lookup remains broken after PATH hydration, provide the observed before/after result for that lookup under the systemd service, and explain how the proposed fixed PATH preserves directories supplied by the user manager? This narrows the unanswered existing request. Please state the tested environment and any checks you could not perform.

      Leaving this open pending that explanation; no new review handoff yet.

    9. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one has merge conflicts with main, does not say which model created it and was opened more than two weeks ago. If this change is still important, please rebuild it on current main with a newer model and note the model in the PR description.

    10. maria-rcks closed this

Sign in to join this conversation.