Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
2a51e1eee7 fix(install): treat bun link . the same as bun link
When running `bun link .` in a directory with a package.json, Bun
was failing with "unrecognised dependency format: ." because `.`
was being processed as a package name to link.

Now `bun link .` correctly registers the current package globally,
matching the behavior of `npm link .`.

Fixes #2686

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 01:01:12 +00:00
2 changed files with 33 additions and 1 deletions

View File

@@ -21,7 +21,11 @@ fn link(ctx: Command.Context) !void {
Output.flush();
}
if (manager.options.positionals.len == 1) {
// Treat `bun link .` the same as `bun link` (register current package)
const is_register = manager.options.positionals.len == 1 or
(manager.options.positionals.len == 2 and std.mem.eql(u8, manager.options.positionals[1], "."));
if (is_register) {
// bun link
var lockfile: Lockfile = undefined;

View File

@@ -0,0 +1,28 @@
import { spawn } from "bun";
import { expect, it } from "bun:test";
import { bunEnv, bunExe, tempDir } from "harness";
// https://github.com/oven-sh/bun/issues/2686
// `bun link .` should work the same as `bun link` (register the current package globally)
it("bun link . should register the current package", async () => {
using dir = tempDir("bun-link-dot", {
"package.json": JSON.stringify({
name: "test-link-dot-pkg",
version: "1.0.0",
}),
});
await using proc = spawn({
cmd: [bunExe(), "link", "."],
cwd: String(dir),
stdout: "pipe",
stderr: "pipe",
env: bunEnv,
});
const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]);
expect(stdout).toContain('Success! Registered "test-link-dot-pkg"');
expect(stderr).not.toContain("unrecognised dependency format");
expect(exitCode).toBe(0);
});