Repository navigation
fix(install): fetch os/cpu metadata during yarn.lock migration - #23143
Conversation
During yarn.lock migration, os/cpu package metadata was not being fetched from the npm registry when missing from yarn.lock. This caused packages with platform-specific requirements to not be properly marked. This change updates fetchNecessaryPackageMetadataAfterYarnOrPnpmMigration to conditionally fetch os/cpu metadata: - For yarn.lock migration: fetches os/cpu metadata from npm registry when not present in yarn.lock (update_os_cpu = true) - For pnpm-lock.yaml migration: skips os/cpu fetching since pnpm-lock.yaml already includes this data (update_os_cpu = false) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Updated 5:04 AM PT - Oct 4th, 2025
❌ @autofix-ci[bot], your commit 8b10a9b has 2 failures in
🧪 To try this PR locally: bunx bun-pr 23143That installs a local version of the PR into your bun-23143 --bun |
WalkthroughAdds a comptime boolean parameter to Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/install/lockfile.zig (1)
954-1046: Replace manager.lockfile. with this.*, gate cache population, and DRY bin cloning*
- Mandatory: replace
manager.lockfile.stringBuilder()and&manager.lockfile.buffers.extern_stringswiththis.stringBuilder()and&this.buffers.extern_stringsto avoid mutating a different Lockfile instance.- Optional: wrap
manager.populateManifestCache(.all)inif (update_os_cpu)so the pnpm path only loads manifests on demand.- Optional: extract the duplicated npm bin-cloning block into a small helper to reduce repetition.
@@ src/install/lockfile.zig:954 - manager.populateManifestCache(.all) catch return; + if (update_os_cpu) manager.populateManifestCache(.all) catch return; @@ - var builder = manager.lockfile.stringBuilder(); + var builder = this.stringBuilder(); @@ - var extern_strings_list = &manager.lockfile.buffers.extern_strings; + var extern_strings_list = &this.buffers.extern_strings;
🧹 Nitpick comments (2)
src/install/lockfile.zig (2)
954-966: Optional: add a scoped debug log when OS/CPU is updated (coding guideline)Add a scoped logger and log when os/arch are filled from the registry. This aids future triage without noise.
pub fn fetchNecessaryPackageMetadataAfterYarnOrPnpmMigration(this: *Lockfile, manager: *PackageManager, comptime update_os_cpu: bool) OOM!void { + const log = bun.Output.scoped(.install, false); @@ - // Update os/cpu metadata if not already set + // Update os/cpu metadata if not already set if (pkg_meta.os == .all) { pkg_meta.os = pkg.package.os; + log("yarn migration: filled os for {s}", .{pkg_name.slice(this.buffers.string_bytes.items)}); } if (pkg_meta.arch == .all) { pkg_meta.arch = pkg.package.cpu; + log("yarn migration: filled arch for {s}", .{pkg_name.slice(this.buffers.string_bytes.items)}); }As per coding guidelines
Also applies to: 999-1005
998-1005: Consider libc as a follow-upIf/when libc metadata is supported in Package.Meta, mirror pnpm handling here to keep parity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
src/install/lockfile.zig(2 hunks)src/install/pnpm.zig(1 hunks)src/install/yarn.zig(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)
Implement debug logs in Zig using
const log = bun.Output.scoped(.${SCOPE}, false);and invokinglog("...", .{})
Files:
src/install/yarn.zigsrc/install/pnpm.zigsrc/install/lockfile.zig
**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/javascriptcore-class.mdc)
**/*.zig: Declare the extern C symbol in Zig and export a Zig-friendly alias for use
Wrap the Bun____toJS extern in a Zig method that takes a JSGlobalObject and returns JSC.JSValue
**/*.zig: Format Zig files with zig-format (bun run zig-format)
In Zig, manage memory carefully with allocators and use defer for cleanup
Files:
src/install/yarn.zigsrc/install/pnpm.zigsrc/install/lockfile.zig
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
🔇 Additional comments (2)
src/install/yarn.zig (1)
1674-1675: Yarn migration now fetches OS/CPU metadata — LGTMPassing true correctly enables the update path after resolve().
src/install/pnpm.zig (1)
822-823: PNPM migration skips OS/CPU fetch — LGTMPassing false aligns with pnpm-lock.yaml already encoding os/cpu.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
test/cli/install/migration/yarn-lock-migration.test.ts (2)
1473-1473: PreferBun.file().text()for consistency.For consistency with other tests in this file (e.g., line 1372), consider using the async
Bun.file()API instead of the synchronousfs.readFileSync().Apply this diff:
- const bunLockContent = fs.readFileSync(join(tempDir, "bun.lock"), "utf8"); + const bunLockContent = await Bun.file(join(tempDir, "bun.lock")).text();
1476-1481: Consider adding explicit OS/CPU metadata assertions.While the snapshot will capture OS/CPU metadata if present, adding explicit assertions would make the test more robust and clearly document what specific metadata the PR introduces. For instance, you could verify that fsevents has
osconstraints or that esbuild packages havearchconstraints in the lockfile structure.Example assertions you could add:
// Verify OS/CPU metadata is present in the lockfile // These are examples - adjust based on the actual lockfile format expect(bunLockContent).toMatch(/"os":\s*\[?"darwin"/); // fsevents should have darwin constraint expect(bunLockContent).toMatch(/"arch":\s*\[?"arm64"/); // esbuild packages should have arch constraints
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
test/cli/install/migration/__snapshots__/yarn-lock-migration.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (1)
test/cli/install/migration/yarn-lock-migration.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
test/**
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Place all tests under the test/ directory
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/cli/**/*.{js,ts}: Place CLI command tests (e.g., bun install, bun init) under test/cli/
When testing Bun as a CLI, use spawn with bunExe() and bunEnv from harness, and capture stdout/stderr via pipes
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/**/*.{js,ts}: Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test
Prefer data-driven tests (e.g., test.each) to reduce boilerplate
Use shared utilities from test/harness.ts where applicable
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.ts
📄 CodeRabbit inference engine (test/CLAUDE.md)
test/**/*.test.ts: Name test files*.test.tsand usebun:test
Do not write flaky tests: never wait for arbitrary time; wait for conditions instead
Never hardcode port numbers in tests; useport: 0to get a random port
When spawning Bun in tests, usebunExe()andbunEnvfromharness
Preferasync/awaitin tests; for a single callback, usePromise.withResolvers()
Do not set explicit test timeouts; rely on Bun’s built-in timeouts
UsetempDir/tempDirWithFilesfromharnessfor temporary files and directories in tests
For large/repetitive strings in tests, preferBuffer.alloc(count, fill).toString()over"A".repeat(count)
Import common test utilities fromharness(e.g.,bunExe,bunEnv,tempDirWithFiles,tmpdirSync, platform checks, GC helpers)
In error tests, assert non-zero exit codes for failing processes and usetoThrowfor synchronous errors
Usedescribeblocks for grouping,describe.eachfor parameterized tests, snapshots withtoMatchSnapshot, and lifecycle hooks (beforeAll,beforeEach,afterEach); track resources for cleanup inafterEach
Useusing/await usingwith Bun resources (e.g., Bun.listen/connect/spawn/serve) to ensure cleanup in tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.test.{ts,tsx}: Test files must live under test/ and end with .test.ts or .test.tsx
In tests, always use port: 0; do not hardcode ports or roll your own random port
Prefer normalizeBunSnapshot for snapshotting test output instead of asserting raw strings
Do not write tests that assert absence of crashes (e.g., 'no panic' or 'no uncaught exception')
Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests
Avoid shell commands like find or grep in tests; use Bun’s Glob and built-in tools instead
Prefer running tests via bun bd test and use provided harness utilities (bunEnv, bunExe, tempDir)
Use Bun.spawn with proper stdio handling and await proc.exited in process-spawning tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place CLI command tests under test/cli/
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
🧬 Code graph analysis (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
test/harness.ts (3)
tempDir(278-285)tempDirWithFiles(260-267)bunExe(103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
🔇 Additional comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1376-1481: LGTM! Test follows best practices.The test structure is well-designed and follows coding guidelines:
- Uses
tempDirWithFilesfor temporary file management- Uses
bunExe()andbunEnvfrom harness- Properly spawns process with stdio handling
- Awaits process exit
- Uses snapshots for comprehensive verification
- Clear test name and good documentation
|
|
||
| "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.17.19", "", {}, "sha512-ct1Mj/VEUqd5+2h0EBPdMzNdGXnGxbLPg6H5TF8xsHY4X5UAP0FUbDKJhtKu+6iLpIjKjWEvb5XrFyZdVy9OTg=="], | ||
|
|
||
| "@esbuild/linux-x64": ["@esbuild/linux-x64@0.17.19", "", {}, "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw=="], |
There was a problem hiding this comment.
hmm not sure if this works? i dont see the os or cpu data.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
228-239: Explicit test timeouts violate coding guidelines.The coding guidelines state: "Do not set explicit test timeouts; rely on Bun's built-in timeouts." However, these changes add explicit 10000ms timeouts to multiple tests. While migration tests may require more time, consider whether the default Bun timeout is sufficient, or if these timeouts are truly necessary for these specific tests.
As per coding guidelines.
Also applies to: 737-739, 1129-1131, 1345-1347, 1359-1361, 1384-1386
🧹 Nitpick comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1388-1493: LGTM! Well-structured test for OS/CPU metadata migration.This test effectively validates the main PR objective: ensuring OS/CPU metadata is fetched from the npm registry during yarn.lock migration. The test setup is realistic, using packages with known platform constraints (fsevents for darwin, esbuild with multiple platforms).
The partial yarn.lock (only 5 of the esbuild platform packages defined) reflects a realistic scenario where not all optional dependencies are resolved in the original lockfile.
Optional: Consider more explicit OS/CPU metadata verification.
While the snapshot at line 1486 captures the complete lockfile structure, you could add explicit assertions to verify the actual os/cpu metadata fields are present in the lockfile, for example:
expect(bunLockContent).toContain("fsevents"); expect(bunLockContent).toContain("@esbuild/linux-arm64"); expect(bunLockContent).toContain("@esbuild/darwin-arm64"); + // Verify OS/CPU metadata is actually present in the lockfile structure + expect(bunLockContent).toMatch(/"os":\s*"darwin"/); + expect(bunLockContent).toMatch(/"cpu":\s*"arm64"/);This would make the test's intent more explicit and provide clearer failure messages if the metadata is missing, rather than relying solely on snapshot comparison.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
test/cli/install/migration/__snapshots__/yarn-lock-migration.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (1)
test/cli/install/migration/yarn-lock-migration.test.ts(6 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
test/**
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Place all tests under the test/ directory
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/cli/**/*.{js,ts}: Place CLI command tests (e.g., bun install, bun init) under test/cli/
When testing Bun as a CLI, use spawn with bunExe() and bunEnv from harness, and capture stdout/stderr via pipes
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/**/*.{js,ts}: Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test
Prefer data-driven tests (e.g., test.each) to reduce boilerplate
Use shared utilities from test/harness.ts where applicable
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.ts
📄 CodeRabbit inference engine (test/CLAUDE.md)
test/**/*.test.ts: Name test files*.test.tsand usebun:test
Do not write flaky tests: never wait for arbitrary time; wait for conditions instead
Never hardcode port numbers in tests; useport: 0to get a random port
When spawning Bun in tests, usebunExe()andbunEnvfromharness
Preferasync/awaitin tests; for a single callback, usePromise.withResolvers()
Do not set explicit test timeouts; rely on Bun’s built-in timeouts
UsetempDir/tempDirWithFilesfromharnessfor temporary files and directories in tests
For large/repetitive strings in tests, preferBuffer.alloc(count, fill).toString()over"A".repeat(count)
Import common test utilities fromharness(e.g.,bunExe,bunEnv,tempDirWithFiles,tmpdirSync, platform checks, GC helpers)
In error tests, assert non-zero exit codes for failing processes and usetoThrowfor synchronous errors
Usedescribeblocks for grouping,describe.eachfor parameterized tests, snapshots withtoMatchSnapshot, and lifecycle hooks (beforeAll,beforeEach,afterEach); track resources for cleanup inafterEach
Useusing/await usingwith Bun resources (e.g., Bun.listen/connect/spawn/serve) to ensure cleanup in tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.test.{ts,tsx}: Test files must live under test/ and end with .test.ts or .test.tsx
In tests, always use port: 0; do not hardcode ports or roll your own random port
Prefer normalizeBunSnapshot for snapshotting test output instead of asserting raw strings
Do not write tests that assert absence of crashes (e.g., 'no panic' or 'no uncaught exception')
Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests
Avoid shell commands like find or grep in tests; use Bun’s Glob and built-in tools instead
Prefer running tests via bun bd test and use provided harness utilities (bunEnv, bunExe, tempDir)
Use Bun.spawn with proper stdio handling and await proc.exited in process-spawning tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place CLI command tests under test/cli/
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
🧬 Code graph analysis (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
test/harness.ts (3)
tempDir(278-285)tempDirWithFiles(260-267)bunExe(103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
🔇 Additional comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1343-1345: LGTM!The new assertion validates that peer dependencies are preserved during migration, which aligns with the test's "realistic complex" scenario.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1480-1485: Strengthen assertions to verify actual OS/CPU metadata structure.The current assertions only check that package names exist in the lockfile content, but don't verify that the OS/CPU metadata (pkg_meta.os, pkg_meta.arch) was actually populated during migration. The comment on lines 1480-1481 mentions specific OS/CPU constraints, but the test doesn't validate them.
Consider adding more explicit assertions that parse the lockfile structure and verify:
- fsevents has os constraint set to darwin
- esbuild platform packages have appropriate arch constraints
- The metadata fields are not empty/default values
This would make the test more robust and explicitly validate the PR's core functionality beyond just snapshot comparison.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
test/cli/install/migration/yarn-lock-migration.test.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
test/**
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Place all tests under the test/ directory
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/cli/**/*.{js,ts}: Place CLI command tests (e.g., bun install, bun init) under test/cli/
When testing Bun as a CLI, use spawn with bunExe() and bunEnv from harness, and capture stdout/stderr via pipes
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/**/*.{js,ts}: Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test
Prefer data-driven tests (e.g., test.each) to reduce boilerplate
Use shared utilities from test/harness.ts where applicable
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.ts
📄 CodeRabbit inference engine (test/CLAUDE.md)
test/**/*.test.ts: Name test files*.test.tsand usebun:test
Do not write flaky tests: never wait for arbitrary time; wait for conditions instead
Never hardcode port numbers in tests; useport: 0to get a random port
When spawning Bun in tests, usebunExe()andbunEnvfromharness
Preferasync/awaitin tests; for a single callback, usePromise.withResolvers()
Do not set explicit test timeouts; rely on Bun’s built-in timeouts
UsetempDir/tempDirWithFilesfromharnessfor temporary files and directories in tests
For large/repetitive strings in tests, preferBuffer.alloc(count, fill).toString()over"A".repeat(count)
Import common test utilities fromharness(e.g.,bunExe,bunEnv,tempDirWithFiles,tmpdirSync, platform checks, GC helpers)
In error tests, assert non-zero exit codes for failing processes and usetoThrowfor synchronous errors
Usedescribeblocks for grouping,describe.eachfor parameterized tests, snapshots withtoMatchSnapshot, and lifecycle hooks (beforeAll,beforeEach,afterEach); track resources for cleanup inafterEach
Useusing/await usingwith Bun resources (e.g., Bun.listen/connect/spawn/serve) to ensure cleanup in tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.test.{ts,tsx}: Test files must live under test/ and end with .test.ts or .test.tsx
In tests, always use port: 0; do not hardcode ports or roll your own random port
Prefer normalizeBunSnapshot for snapshotting test output instead of asserting raw strings
Do not write tests that assert absence of crashes (e.g., 'no panic' or 'no uncaught exception')
Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests
Avoid shell commands like find or grep in tests; use Bun’s Glob and built-in tools instead
Prefer running tests via bun bd test and use provided harness utilities (bunEnv, bunExe, tempDir)
Use Bun.spawn with proper stdio handling and await proc.exited in process-spawning tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place CLI command tests under test/cli/
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
🧬 Code graph analysis (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
test/harness.ts (3)
tempDir(278-285)tempDirWithFiles(260-267)bunExe(103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1371-1372: Consider using the consistent pattern for async assertions.Lines 1371-1372 use Jest's
.resolvesmatcher, while the rest of the file consistently uses theawaitpattern (e.g., lines 47, 144, 208, 1324-1325). Similarly, line 1372 usesBun.file().exists()while other tests usefs.existsSync()(lines 48, 145, 212, 731, etc.).Apply this diff to match the file's established pattern:
- expect(migrateResult.exited).resolves.toBe(0); - expect(Bun.file(join(tempDir, "bun.lock")).exists()).resolves.toBe(true); + const exitCode = await migrateResult.exited; + expect(exitCode).toBe(0); + expect(fs.existsSync(join(tempDir, "bun.lock"))).toBe(true);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
test/cli/install/migration/yarn-lock-migration.test.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
test/**
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Place all tests under the test/ directory
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/cli/**/*.{js,ts}: Place CLI command tests (e.g., bun install, bun init) under test/cli/
When testing Bun as a CLI, use spawn with bunExe() and bunEnv from harness, and capture stdout/stderr via pipes
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
test/**/*.{js,ts}: Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test
Prefer data-driven tests (e.g., test.each) to reduce boilerplate
Use shared utilities from test/harness.ts where applicable
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.ts
📄 CodeRabbit inference engine (test/CLAUDE.md)
test/**/*.test.ts: Name test files*.test.tsand usebun:test
Do not write flaky tests: never wait for arbitrary time; wait for conditions instead
Never hardcode port numbers in tests; useport: 0to get a random port
When spawning Bun in tests, usebunExe()andbunEnvfromharness
Preferasync/awaitin tests; for a single callback, usePromise.withResolvers()
Do not set explicit test timeouts; rely on Bun’s built-in timeouts
UsetempDir/tempDirWithFilesfromharnessfor temporary files and directories in tests
For large/repetitive strings in tests, preferBuffer.alloc(count, fill).toString()over"A".repeat(count)
Import common test utilities fromharness(e.g.,bunExe,bunEnv,tempDirWithFiles,tmpdirSync, platform checks, GC helpers)
In error tests, assert non-zero exit codes for failing processes and usetoThrowfor synchronous errors
Usedescribeblocks for grouping,describe.eachfor parameterized tests, snapshots withtoMatchSnapshot, and lifecycle hooks (beforeAll,beforeEach,afterEach); track resources for cleanup inafterEach
Useusing/await usingwith Bun resources (e.g., Bun.listen/connect/spawn/serve) to ensure cleanup in tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.test.{ts,tsx}: Test files must live under test/ and end with .test.ts or .test.tsx
In tests, always use port: 0; do not hardcode ports or roll your own random port
Prefer normalizeBunSnapshot for snapshotting test output instead of asserting raw strings
Do not write tests that assert absence of crashes (e.g., 'no panic' or 'no uncaught exception')
Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests
Avoid shell commands like find or grep in tests; use Bun’s Glob and built-in tools instead
Prefer running tests via bun bd test and use provided harness utilities (bunEnv, bunExe, tempDir)
Use Bun.spawn with proper stdio handling and await proc.exited in process-spawning tests
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
test/cli/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place CLI command tests under test/cli/
Files:
test/cli/install/migration/yarn-lock-migration.test.ts
🧠 Learnings (1)
📚 Learning: 2025-09-03T17:10:13.486Z
Learnt from: CR
PR: oven-sh/bun#0
File: test/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:10:13.486Z
Learning: Applies to test/**/*.test.ts : Do not set explicit test timeouts; rely on Bun’s built-in timeouts
Applied to files:
test/cli/install/migration/yarn-lock-migration.test.ts
🧬 Code graph analysis (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
test/harness.ts (3)
tempDir(278-285)tempDirWithFiles(260-267)bunExe(103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
🔇 Additional comments (1)
test/cli/install/migration/yarn-lock-migration.test.ts (1)
1378-1483: LGTM! Well-structured test for OS/CPU metadata migration.The new test correctly validates the PR's objective of fetching OS/CPU metadata during yarn.lock migration. It:
- Creates a realistic test case with platform-specific packages (fsevents, esbuild)
- Uses consistent patterns with the rest of the file (
await Promise.all,fs.existsSync)- Employs snapshot-based verification for lockfile format validation
- Includes sanity checks for platform-specific packages in the migrated lockfile
Summary
During
yarn.lockmigration, OS/CPU package metadata was not being fetched from the npm registry when missing fromyarn.lock. This caused packages with platform-specific requirements to not be properly marked, potentially leading to incorrect package installation behavior.Changes
Updated
fetchNecessaryPackageMetadataAfterYarnOrPnpmMigrationto conditionally fetch OS/CPU metadata:update_os_cpu = true)update_os_cpu = false)Files Modified
src/install/lockfile.zig- Added comptimeupdate_os_cpuparameter and conditional logic to fetch OS/CPU metadatasrc/install/yarn.zig- Passtrueto enable OS/CPU fetching for yarn migrationssrc/install/pnpm.zig- Passfalseto skip OS/CPU fetching for pnpm migrations (already parsed from lockfile)Why This Approach
yarn.lockformat often doesn't include OS/CPU constraints, requiring us to fetch from npm registrypnpm-lock.yamlalready parses OS/CPU during migration (lines 618-621 in pnpm.zig), making additional fetching redundantTesting
pkg_meta.osandpkg_meta.archonly when:update_os_cpuistrue(yarn migration).all(not already set)🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com