GeezerVison is showing github.com — fix(server): browser setup command names the running t3 executable, n… · pingdotgg/t3code@b63b559
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/cli/invocation.test.ts +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,6 +109,37 @@ it.layer(NodeServices.layer)("root CLI commands", (it) => { | 109 | 109 | }), | 110 | 110 | ).toBe("sudo /opt/t3/t3 browser setup"); | 111 | 111 |
| | 112 | + // A standalone executable started directly (systemd, no launcher) is still this install. | | 113 | + expect( | | 114 | + yield* rootCommand({ | | 115 | + node: "/opt/t3/t3", | | 116 | + entry: "/opt/t3/t3", | | 117 | + executable: true, | | 118 | + path: yield* pathWithT3, | | 119 | + }), | | 120 | + ).toBe("sudo /opt/t3/t3 browser setup"); | | 121 | + | | 122 | + // A global npm launcher runs the downloaded executable; PATH's `t3` is that launcher. | | 123 | + const prefix = path.join(home, "npm"); | | 124 | + const npmLauncher = path.join(prefix, "lib/node_modules/t3/bin/t3.mjs"); | | 125 | + yield* fs.makeDirectory(path.dirname(npmLauncher), { recursive: true }); | | 126 | + yield* fs.makeDirectory(path.join(prefix, "bin")); | | 127 | + yield* fs.writeFileString(npmLauncher, "", { mode: 0o755 }); | | 128 | + yield* fs.writeFileString( | | 129 | + path.join(prefix, "lib/node_modules/t3/package.json"), | | 130 | + `{"name":"t3","version":"${packageJson.version}"}`, | | 131 | + ); | | 132 | + yield* fs.symlink(npmLauncher, path.join(prefix, "bin/t3")); | | 133 | + expect( | | 134 | + yield* rootCommand({ | | 135 | + node: "/home/theo/.t3/runtime/versions/1.0.0/t3", | | 136 | + entry: "/home/theo/.t3/runtime/versions/1.0.0/t3", | | 137 | + executable: true, | | 138 | + path: path.join(prefix, "bin"), | | 139 | + env: { T3CODE_NPM_LAUNCHER_PATH: npmLauncher }, | | 140 | + }), | | 141 | + ).toBe('sudo env "PATH=$PATH" t3 browser setup'); | | 142 | + | 112 | 143 | expect( | 113 | 144 | yield* rootCommand({ ...desktop, env: { T3CODE_CLI_PATH: path.join(home, "gone") } }), | 114 | 145 | ).toBe('sudo env "PATH=$PATH" t3 browser setup'); | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/cli/invocation.ts +11-2Lines changed: 11 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -160,8 +160,17 @@ export const resolveHostCliCommand = Effect.fn("invocation.resolveHostCliCommand | 160 | 160 | const shim = (yield* HostProcess.Environment).T3CODE_CLI_PATH?.trim(); | 161 | 161 | const fs = yield* FileSystem.FileSystem; | 162 | 162 | const real = (file: string) => fs.realPath(file).pipe(Effect.orElseSucceed(() => null)); | 163 | | - const shimReal = shim ? yield* real(shim) : null; | 164 | | - if (shimReal === null || shimReal === (yield* real(onPath))) { | | 163 | + // Windows `t3.cmd` shims are text files that never realpath to the executable they run. | | 164 | + const own = shim | | 165 | + ? yield* real(shim) | | 166 | + : platform !== "win32" && (yield* HostProcess.IsExecutable) | | 167 | + ? yield* resolveEntryPath.pipe( | | 168 | + Effect.flatMap((entry) => | | 169 | + real(entry).pipe(Effect.map((resolved) => resolved ?? entry)), | | 170 | + ), | | 171 | + ) | | 172 | + : null; | | 173 | + if (own === null || own === (yield* real(onPath))) { | 165 | 174 | return { command: withArgs(command), launcher: false }; | 166 | 175 | } | 167 | 176 | } | |
|