Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: `Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.` #21681

Closedpaperbenni(GitHub profile, opens in a new tab) opened this issue 4 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.

Add a normal Arch linux machine over ssh

  • node and bun are installed over mise
  • ssh works fine, herdr, zed, vs code remotes work fine
  • npx t3 on the machine itself works fine

Expected behavior

it installs current t3 code and connects to the server

Actual behavior

Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.

this error message

Impact

Blocks work completely

Version or commit

0.1.0

Environment

Arch linux, Ryzen CPU, Wayland compositor, sshd enabled

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

No response

  1. paperbenni(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Note

    Grok responding on behalf of Julius.

    We need more detail to tell why the remote server rejected the pairing credential. A 401 at this step means the remote T3 server answered and refused the credential the desktop created over SSH (sshEnvironment.ts:63-65). So the remote launch and node lookup, including mise, had already worked. The launcher also adds mise shims to PATH (tunnel.ts:387-391).

    The launcher reuses a T3 server that is already running from the default home instead of starting its own (tunnel.ts:652-690). It then creates the pairing credential with the launcher's own t3 runner against that default home (tunnel.ts:750-760). A server you started yourself with npx t3 can end up being the one that receives it.

    Please reply with:

    1. Whether a t3 server you started yourself was running on the host when you connected, and whether connecting works with it stopped.
    2. The npx t3 version on the host.
    3. The contents of server.log under ~/.t3/ssh-launch on the host.
  3. juliusmarminge added labelsneeds more info

  4. juliusmarminge added labelsvia-triage

  5. juliusmarminge removed labelsneeds-triage

  6. juliusmarminge removed labelsbug

  7. An older t3 server was already running, manually sshing into the server killing t3 there and doing npx t3 service install fixed the issue. It would be nice if t3 code would show a nicer error message though or would even do this for me.

  8. Gooder24(GitHub profile, opens in a new tab)commented

    Same 401 on another host. Here's the diagnosis you asked for above.

    What happened

    The desktop updated to 0.1.0. After that, an SSH environment showed Reconnecting: Could not prepare the SSH environment on every retry.

    Diagnosis

    An older server, 0.0.45, was still running from the remote ~/.t3. The launcher adopted it as external and minted the pairing grant with its own 0.1.0 runner. The 0.1.0 CLI writes grants to statev2.sqlite, but the 0.0.45 server reads state.sqlite, so /oauth/token rejected the grant.

    On this host nobody started the old server by hand. The desktop had launched it as managed under the state key of the connection's previous alias. After the alias changed, the new key adopted the server as external, so no update would ever replace it.

    Steps to reproduce

    Derived from the logs and the launch script, not replayed end to end:

    1. Connect an SSH environment with an older desktop and let it launch the remote server.
    2. Change the connection's alias, user, or port, then reconnect. The launch now reports remoteServerKind: "external".
    3. Update the desktop to a release whose CLI writes a different database, such as 0.0.45 → 0.1.0, and reconnect.

    Version

    Desktop 0.1.0. Remote server 0.0.45, with the 0.1.0 runtime installed next to it by the launcher.

    Environment

    The desktop runs on Arch Linux under Wayland. The remote is Ubuntu 24.04 x64 with the release-archive runtime and no Node.

    Evidence

    Desktop trace:

    ssh.environment.ensure.succeeded { remotePort: 3773, remoteServerKind: "external", issuedPairingToken: true }
    DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.
      [cause]: EnvironmentAuthInvalidError: The environment rejected this client's credentials (invalid_credential).

    Remote server trace:

    environment.auth.token POST /oauth/token -> EnvironmentAuthInvalidError (invalid_credential)
      at environment.auth.token (file:///<home>/.t3/runtime/versions/0.0.45/t3)

    On the remote, t3 serve ran from runtime/versions/0.0.45 and held only state.sqlite open, while the launcher's run-t3.sh pinned T3_ARCHIVE_VERSION='0.1.0'. The first pairing attempt with the 0.1.0 CLI created statev2.sqlite. The 0.0.45 server kept writing state.sqlite for about five more hours.

    • #17550 pairs reused servers with their own CLI version. That fixes the pairing side and covers this report.
    • #21892 keeps a server the launcher started managed after a connection edit, so updates still replace it.

    Fix applied or workaround

    I stopped the 0.0.45 server, moved the stale statev2.sqlite* aside, and let the desktop relaunch. The 0.1.0 server imported the current state.sqlite, and the desktop connected.

    If you recovered by stopping the old server, check your data. The new server imports V1 only when statev2.sqlite is missing, so anything written after the first failed pairing is not in V2. state.sqlite is left untouched, so stopping the server, moving statev2.sqlite* aside, and starting it again imports it once more.

    Filed by

    Claude Opus 5.5 in Claude Code, run from T3 Code.

  9. Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Thanks for the report. One part of this is fixed in current main. Merged #17550 mints pairing credentials with the runtime of a reused managed server, fixing the reported old-server credential mismatch. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: a managed server can still be adopted as external after the SSH alias changes. If that part still matters to you, please open a new issue for that part only.

Sign in to join this conversation.