Skip to content

bun: Persist user data#7697

Merged
z-Fng merged 2 commits intoScoopInstaller:masterfrom
A-Words:fix/bun-persist-dir
Mar 8, 2026
Merged

bun: Persist user data#7697
z-Fng merged 2 commits intoScoopInstaller:masterfrom
A-Words:fix/bun-persist-dir

Conversation

@A-Words
Copy link
Contributor

@A-Words A-Words commented Feb 28, 2026

Closes #7696

  • Use conventional PR title: <manifest-name[@version]|chore>: <general summary of the pull request>
  • I have read the Contributing Guide

Summary

Fix bun manifest so Bun data is persisted under Scoop persist directory, and add safe migration for legacy %USERPROFILE%\.bun.

Changes

  • Add env_set:
    • BUN_INSTALL=$persist_dir
  • Add env_add_path:
    • "bin"
  • Add persist:
    • "bin", "install"
  • Extend pre_install:
    • migrate %USERPROFILE%\.bun to $persist_dir when persist dir does not exist
    • if both paths exist, skip migration and print warning to avoid overwrite
  • Keep existing AVX2 selection / download / hash / autoupdate logic unchanged

Validation

  • bucket/bun.json parses successfully (ConvertFrom-Json)
  • scoop cat .\bucket\bun.json shows expected new fields
  • bin/test.ps1 could not be executed locally due to missing module: BuildHelpers

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for ARM64 architecture on Windows
    • Introduced automatic CPU feature detection for optimal binary selection
    • Implemented legacy data migration from previous installation paths
    • Added persistent storage for installation data across sessions
  • Chores

    • Updated environment configuration and installation process

@github-actions
Copy link
Contributor

All changes look good.

Wait for review from human collaborators.

bun

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate
  • Autoupdate Hash Extraction

Check the full log for details.

@A-Words A-Words force-pushed the fix/bun-persist-dir branch from 57b2565 to 6b2a242 Compare February 28, 2026 08:56
@z-Fng z-Fng changed the title bun: persist global data in Scoop persist dir and migrate legacy ~/.bun bun: Persist user data Mar 8, 2026
@z-Fng
Copy link
Member

z-Fng commented Mar 8, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 8, 2026

📝 Walkthrough

Walkthrough

Modified the bun package manifest to add Scoop persistence configuration, legacy data migration support, environment variable setup, and architecture-aware binary selection logic for Windows installations.

Changes

Cohort / File(s) Summary
Bun Persistence Configuration
bucket/bun.json
Added pre_install block with legacy data migration from legacy path to persist directory; introduced env_add_path (bin), env_set (BUN_INSTALL pointing to persist directory), and persist configuration (bin, install). Implemented architecture-based binary selection logic: arm64 targets bun-windows-aarch64, x64 targets bun-windows-x64 with optional -baseline suffix based on AVX2 CPU feature detection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'bun: Persist user data' is clear and directly related to the main change: implementing data persistence for the bun package manager.
Description check ✅ Passed The PR description follows the template with proper sections: it closes issue #7696, includes a clear summary, detailed changes, and validation results.
Linked Issues check ✅ Passed The PR fully addresses issue #7696 requirements: adds persist configuration, sets BUN_INSTALL to persist_dir, includes migration logic for legacy data, and maintains existing functionality.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing persistence for bun data as specified in issue #7696; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
bucket/bun.json (1)

25-33: Consider adding error handling for the migration step.

The migration logic is sound—it correctly handles both the happy path (legacy exists, persist doesn't) and the conflict case (both exist). However, Move-Item can fail if files are locked or permissions are denied, which would cause a cryptic error during installation.

♻️ Suggested improvement with try/catch
     "if ((Test-Path $legacy_bun) -and -not (Test-Path $persist_dir)) {",
     "    Write-Host \"Migrating legacy Bun data from '$legacy_bun' to '$persist_dir'.\" -ForegroundColor Yellow",
-    "    Move-Item $legacy_bun $persist_dir -Force",
+    "    try { Move-Item $legacy_bun $persist_dir -Force -ErrorAction Stop }",
+    "    catch { Write-Host \"Migration failed: $_. Please migrate manually.\" -ForegroundColor Red }",
     "} elseif ((Test-Path $legacy_bun) -and (Test-Path $persist_dir)) {",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/bun.json` around lines 25 - 33, Wrap the Move-Item call in a try/catch
to handle failures: surround the block that moves $legacy_bun to $persist_dir
(the existing Move-Item invocation) with try { Move-Item ... } catch {
Write-Host "Failed to migrate '$legacy_bun' to '$persist_dir':
$($_.Exception.Message)" -ForegroundColor Red; Write-Host $_.Exception
-ForegroundColor Red; exit 1 } so errors (locked files/permission issues) are
logged with details and the install exits non-zero; keep the existing conflict
branch intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bucket/bun.json`:
- Around line 25-33: Wrap the Move-Item call in a try/catch to handle failures:
surround the block that moves $legacy_bun to $persist_dir (the existing
Move-Item invocation) with try { Move-Item ... } catch { Write-Host "Failed to
migrate '$legacy_bun' to '$persist_dir': $($_.Exception.Message)"
-ForegroundColor Red; Write-Host $_.Exception -ForegroundColor Red; exit 1 } so
errors (locked files/permission issues) are logged with details and the install
exits non-zero; keep the existing conflict branch intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59c83d91-622d-43c3-a8f9-bcbd5f706429

📥 Commits

Reviewing files that changed from the base of the PR and between 7c1503f and 4828467.

📒 Files selected for processing (1)
  • bucket/bun.json

Copy link
Member

@z-Fng z-Fng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@z-Fng z-Fng merged commit c52b2d7 into ScoopInstaller:master Mar 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bun does not persist to Scoop persist directory

2 participants