diff --git a/apps/server/src/cli/install.test.ts b/apps/server/src/cli/install.test.ts index 104718a568cd..f7aaeca3120c 100644 --- a/apps/server/src/cli/install.test.ts +++ b/apps/server/src/cli/install.test.ts @@ -72,13 +72,20 @@ it.layer(NodeServices.layer)("t3 install", (it) => { // Another t3 earlier on PATH still runs first, so `t3` would not run this one. const otherBin = path.join(root, "other-bin"); yield* fs.makeDirectory(otherBin); - yield* fs.writeFileString(path.join(otherBin, "t3"), ""); + yield* fs.writeFileString(path.join(otherBin, "t3"), "", { mode: 0o755 }); const shadowed = yield* provide(installCli(), { PATH: `${otherBin}:${path.join(root, "bin")}`, }); assert.isFalse(shadowed.onPath); assert.equal(shadowed.shadowedBy, path.join(otherBin, "t3")); assert.isUndefined(shadowed.pathCommand); + yield* fs.remove(path.join(otherBin, "t3")); + yield* fs.makeDirectory(path.join(otherBin, "t3")); + const directory = yield* provide(installCli(), { + PATH: `${otherBin}:${path.join(root, "bin")}`, + }); + assert.isTrue(directory.onPath); + assert.isUndefined(directory.shadowedBy); const recorded = yield* fs.readFileString(path.join(runtimeDir, "launchers")); assert.equal(recorded, `\n${yield* fs.realPath(path.join(root, "bin"))}/t3\n`); diff --git a/apps/server/src/cli/install.ts b/apps/server/src/cli/install.ts index b95e1ffefb35..4e6420842dc9 100644 --- a/apps/server/src/cli/install.ts +++ b/apps/server/src/cli/install.ts @@ -1,5 +1,5 @@ import * as HostProcess from "@t3tools/shared/HostProcess"; -import { pathSetupCommand } from "@t3tools/shared/shell"; +import { pathSetupCommand, resolveCommandPath } from "@t3tools/shared/shell"; import * as Console from "effect/Console"; import * as Duration from "effect/Duration"; import * as Effect from "effect/Effect"; @@ -156,7 +156,7 @@ export const installCli = Effect.fn("cli.install.install")(function* () { if (!path.isAbsolute(entry) || detectCliRunner(`${entry}/`) !== null) continue; for (const name of windows ? ["t3.cmd", "t3.exe"] : ["t3"]) { const candidate = path.join(entry, name); - if (yield* fs.exists(candidate).pipe(Effect.orElseSucceed(() => false))) return candidate; + if (yield* resolveCommandPath(candidate, { env: environment })) return candidate; } } return undefined;