GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(shared): search cwd for empty POSIX PATH components by Motaghi · Pull Request #28106 · pingdotgg/t3code

fix(shared): search cwd for empty POSIX PATH components #28106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 17 commits into pingdotgg:main from Motaghi:behmot/posix-empty-path-components-20261031
Nov 23, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(shared): search cwd for empty POSIX PATH components #28106

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
686e7f1
fix(shared): search cwd for empty POSIX PATH components
Motaghi Oct 31, 2026
4b1f3c5
fix(shared): scope relative PATH caches to the working directory
Motaghi Oct 31, 2026
4255544
no-mistakes(review): Scope macOS Git caches to relative PATH cwd
Motaghi Oct 31, 2026
f838d61
no-mistakes(lint): Format shell regression test destructuring
Motaghi Oct 31, 2026
29c7cd2
fix(shared): keep absolute PATH lookup working when cwd cannot be read
Motaghi Nov 17, 2026
aebdce8
fix(server): anchor cwd provider executables before scoped launch
maria-rcks Nov 18, 2026
0881188
fix(shared): anchor executables found through empty PATH components
Motaghi Nov 18, 2026
15855b7
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 19, 2026
78aec4c
fix(shared,server): keep absolute agent paths as spelled and probe th…
Motaghi Nov 19, 2026
22aef07
test(server): skip the symlinked-parent agentScope case where symlink…
Motaghi Nov 19, 2026
6e62d1c
fix(server): anchor relative agent paths for systemd-run without coll…
Motaghi Nov 19, 2026
9f21982
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 22, 2026
81e9154
fix(shared): share the cwd snapshot with PATH searches and launch the…
Motaghi Nov 22, 2026
669eac2
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 22, 2026
fcf8241
Merge remote-tracking branch 'origin/main' into behmot/posix-empty-pa…
juliusmarminge Nov 23, 2026
49c91bb
test(shared): trim empty PATH component tests to the regressions
juliusmarminge Nov 23, 2026
6dfeac2
fix(shared): keep relative PATH probes valid after the cwd is renamed
juliusmarminge Nov 23, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(shared): keep absolute PATH lookup working when cwd cannot be read
process.cwd() throws when the working directory was removed. pathSearchCwd
now reports that case as null: relative entries then skip the directory
listing cache, and the command caches are neither read nor written, so
absolute entries are still searched and nothing is cached under a key
without cwd.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@Motaghi
Motaghi committed Nov 17, 2026
commit 29c7cd2e8d3dc9a30634d48643f6daa65834f5ea

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

74 changes: 74 additions & 0 deletions 74 packages/shared/src/shell.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,80 @@ console.log(JSON.stringify({ resolved, resolvedGit }));
);
}),
);

// Deleting the working directory makes process.cwd() throw, so this also runs in a child.
const resolveWithoutCwd = `
import { createRequire } from "node:module";
import * as NodeFS from "node:fs";
const [shellPath, command, PATH, removed, gitShim, xcodeGit] = process.argv.slice(1);
const requireFromShell = createRequire(shellPath);
const Effect = await import(requireFromShell.resolve("effect/Effect"));
const { layer } = await import(requireFromShell.resolve("@effect/platform-node/NodeServices"));
const HostProcess = await import(shellPath.replace(/shell\\.ts$/, "HostProcess.ts"));
const Shell = await import(shellPath);
const defaultResolver = Shell.SpawnExecutableResolution.defaultValue();
const resolveExecutable = (...args) => {
const found = defaultResolver(...args);
return found === gitShim ? "/usr/bin/git" : found;
};
process.chdir(removed);
NodeFS.rmdirSync(removed);
const cache = new Map();
const result = await Effect.runPromise(Effect.gen(function* () {
const effect = yield* Shell.resolveCommandPath(command, { env: { PATH } }).pipe(
Effect.provideService(HostProcess.Platform, process.platform),
);
const git = yield* Shell.resolveSpawnCommand("git", ["status"], { env: { PATH } }).pipe(
Effect.provideService(HostProcess.Platform, "darwin"),
Effect.provideService(Shell.SpawnExecutableResolution, resolveExecutable),
Effect.provideService(Shell.XcodeGitLocation, () => xcodeGit),
);
return { effect, git: git.command };
}).pipe(
Effect.provideService(Shell.CommandResolutionCache, cache),
Shell.withPathDirectoryListings,
Effect.provide(layer),
));
console.log(JSON.stringify({ ...result, cached: cache.size }));
`;

it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
"searches absolute PATH entries and caches nothing when the working directory is gone",
() =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const listed = yield* fs.makeTempDirectoryScoped({ prefix: "t3-gone-cwd-listed-" });
const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-gone-cwd-parent-" });
const removed = path.join(parent, "removed");
yield* fs.makeDirectory(removed);
const command = "t3-gone-cwd-cli";
const inListed = path.join(listed, command);
const gitShim = path.join(listed, "git");
const xcodeGit = path.join(listed, "xcode-git");
yield* fs.writeFileString(inListed, "#!/bin/sh\n", { mode: 0o755 });
yield* fs.writeFileString(gitShim, "#!/bin/sh\n", { mode: 0o755 });
yield* fs.writeFileString(xcodeGit, "#!/bin/sh\n", { mode: 0o755 });

const stdout = NodeChildProcess.execFileSync(
process.execPath,
[
"--input-type=module",
"-e",
resolveWithoutCwd,
path.join(import.meta.dirname, "shell.ts"),
command,
`:${listed}`,
removed,
gitShim,
xcodeGit,
],
{ cwd: parent, encoding: "utf8", env: {} },
);

expect(JSON.parse(stdout)).toEqual({ effect: inListed, git: xcodeGit, cached: 0 });
}),
);
});

describe("runsGitWithoutConsole", () => {
Expand Down
32 changes: 20 additions & 12 deletions 32 packages/shared/src/shell.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,19 @@ function pathEntriesForPlatform(pathValue: string, platform: NodeJS.Platform): s
}

// Relative POSIX PATH entries resolve against the working directory, so caches keyed by them include it.
function pathSearchCwd(pathValue: string, platform: NodeJS.Platform): string | undefined {
// null: a relative entry is present but the working directory cannot be read, so nothing is cached.
function pathSearchCwd(pathValue: string, platform: NodeJS.Platform): string | null | undefined {
if (platform === "win32") return undefined;
return pathEntriesForPlatform(pathValue, platform).some(
(entry) => !NodePath.posix.isAbsolute(entry),
)
? process.cwd()
: undefined;
if (
pathEntriesForPlatform(pathValue, platform).every((entry) => NodePath.posix.isAbsolute(entry))
) {
return undefined;
}
try {
return process.cwd();
} catch {
return null;
}
}

// Called within the traced command resolvers.
Expand All @@ -711,8 +717,10 @@ const findOnPath = Effect.fnUntraced(function* (
const listings = yield* PathDirectoryListings;
const matches: string[] = [];
for (const pathEntry of pathEntries) {
const directory = cwd === undefined ? pathEntry : path.resolve(cwd, pathEntry);
let listing = listings && (yield* Cache.get(listings, directory));
const directory = cwd === undefined || cwd === null ? pathEntry : path.resolve(cwd, pathEntry);
// Without a readable cwd a relative entry has no stable directory, so it skips the listing cache.
const uncached = cwd === null && !NodePath.posix.isAbsolute(pathEntry);
let listing = listings && !uncached ? yield* Cache.get(listings, directory) : undefined;
if (listings && listing?.names && listing.modified !== (yield* directoryMtime(directory))) {
yield* Cache.invalidate(listings, directory);
listing = yield* Cache.get(listings, directory);
Expand Down Expand Up @@ -769,7 +777,7 @@ const resolveCommandPathForPlatform = Effect.fn("shell.resolveCommandPathForPlat
].join(COMMAND_RESOLUTION_CACHE_KEY_SEPARATOR);
const cache = yield* CommandResolutionCache;
const nowNanos = yield* Clock.monotonicTimeNanos;
const cached = cache.get(cacheKey);
const cached = cwd === null ? undefined : cache.get(cacheKey);
if (cached !== undefined && cached.expiresAtNanos > nowNanos) {
return cached.resolvedPath;
}
Expand All @@ -781,7 +789,7 @@ const resolveCommandPathForPlatform = Effect.fn("shell.resolveCommandPathForPlat
windowsPathExtensions,
() => true,
);
cacheCommandResolution(cache, cacheKey, resolvedPath, nowNanos);
if (cwd !== null) cacheCommandResolution(cache, cacheKey, resolvedPath, nowNanos);
return resolvedPath;
});

Expand Down Expand Up @@ -932,7 +940,7 @@ const resolveMacosGit = Effect.fnUntraced(function* (
...(cwd === undefined ? [] : [cwd]),
].join(COMMAND_RESOLUTION_CACHE_KEY_SEPARATOR);
const nowNanos = yield* Clock.currentTimeNanos;
const cached = cache.get(cacheKey);
const cached = cwd === null ? undefined : cache.get(cacheKey);
// An Xcode update or removal deletes the binary; look again instead of failing the spawn.
if (
cached !== undefined &&
Expand All @@ -948,7 +956,7 @@ const resolveMacosGit = Effect.fnUntraced(function* (
located !== undefined && resolveExecutable(located, "darwin", env) !== undefined
? located
: null;
cacheCommandResolution(cache, cacheKey, realGit, nowNanos);
if (cwd !== null) cacheCommandResolution(cache, cacheKey, realGit, nowNanos);
return realGit ?? "git";
});

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.