Compare commits

...

2 Commits

Author SHA1 Message Date
Claude Bot
2a786ec6ff refactor(test): use tempDir pattern and remove custom timeout
Address review feedback: replace tmpdirSync/beforeEach with the `using`
tempDir pattern for automatic cleanup, and remove unnecessary
setDefaultTimeout/beforeAll.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-12 15:09:54 +00:00
Claude Bot
08d7426fd0 fix(install): silently ignore missing literal workspace paths
Previously, `bun install` would error with "Workspace not found" when a
literal workspace path (e.g. "terraform") didn't exist, but silently
succeed when a glob pattern (e.g. "terraform*") matched nothing. This
inconsistency differed from npm, which treats both cases identically
with silent success.

Now both literal and glob workspace paths that don't resolve to a valid
package.json are silently skipped, matching npm behavior.

Closes #26970

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-12 14:52:29 +00:00
3 changed files with 85 additions and 12 deletions

View File

@@ -153,15 +153,7 @@ pub fn processNamesArray(
) catch |err| {
bun.handleErrorReturnTrace(err, @errorReturnTrace());
switch (err) {
error.EISNOTDIR, error.EISDIR, error.EACCESS, error.EPERM, error.ENOENT, error.FileNotFound => {
log.addErrorFmt(
source,
item.loc,
allocator,
"Workspace not found \"{s}\"",
.{input_path},
) catch {};
},
error.EISNOTDIR, error.EISDIR, error.EACCESS, error.EPERM, error.ENOENT, error.FileNotFound => {},
error.MissingPackageName => {
log.addErrorFmt(
source,

View File

@@ -34,9 +34,9 @@ test("bad workspace path", () => {
});
const text = stderr!.toString();
expect(text).toContain('Workspace not found "i-dont-exist"');
expect(exitCode).toBe(1);
// Missing workspace paths are silently ignored, matching npm behavior
expect(text).not.toContain('Workspace not found "i-dont-exist"');
expect(exitCode).toBe(0);
});
test("workspace with ./ should not crash", () => {

View File

@@ -0,0 +1,81 @@
import { spawnSync } from "bun";
import { expect, test } from "bun:test";
import { bunEnv, bunExe, tempDir } from "harness";
test("missing literal workspace path should not error", () => {
using dir = tempDir("issue-26970", {
"package.json": JSON.stringify({
name: "test",
workspaces: ["terraform"],
}),
});
const { stderr, exitCode } = spawnSync({
cmd: [bunExe(), "install"],
cwd: String(dir),
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
const text = stderr!.toString();
expect(text).not.toContain("Workspace not found");
expect(exitCode).toBe(0);
});
test("missing glob workspace pattern should not error", () => {
using dir = tempDir("issue-26970", {
"package.json": JSON.stringify({
name: "test",
workspaces: ["terraform*"],
}),
});
const { stderr, exitCode } = spawnSync({
cmd: [bunExe(), "install"],
cwd: String(dir),
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
const text = stderr!.toString();
expect(text).not.toContain("Workspace not found");
expect(exitCode).toBe(0);
});
test("literal and glob missing workspaces behave the same", () => {
using literalDir = tempDir("issue-26970", {
"package.json": JSON.stringify({
name: "test",
workspaces: ["nonexistent"],
}),
});
const literalResult = spawnSync({
cmd: [bunExe(), "install"],
cwd: String(literalDir),
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
using globDir = tempDir("issue-26970", {
"package.json": JSON.stringify({
name: "test",
workspaces: ["nonexistent*"],
}),
});
const globResult = spawnSync({
cmd: [bunExe(), "install"],
cwd: String(globDir),
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
// Both should succeed with exit code 0
expect(literalResult.exitCode).toBe(0);
expect(globResult.exitCode).toBe(0);
});