Implements offline mode for `bun install` that allows installing packages using only locally cached manifests and tarballs, without any network connectivity.
Unlike other package managers, Bun's offline mode can work without an existing lockfile by using cached package manifests to resolve versions.
Key changes:
- Added --offline CLI flag to CommandLineArguments.zig
- Added offline configuration field to PackageManagerOptions.zig
- Modified manifest cache to skip expiry checks in offline mode (PackageManifestMap.zig)
- Added early returns with error messages when packages/tarballs not in cache:
- PopulateManifestCache.zig: Handles manifest fetching errors
- PackageManagerEnqueue.zig: Prevents tarball downloads and git checkouts
- Prevented network queue flushing in offline mode (runTasks.zig)
- Added user-facing "Installing in offline mode" message (install_with_manager.zig)
- Added debug assertions to catch network tasks created in offline mode (NetworkTask.zig)
- Handled OfflineModePackageNotCached error in PackageInstaller.zig and isolated_install.zig
- Optional dependencies fail silently in offline mode
- Git dependencies are not supported in offline mode
Tests include:
- Successful install with cached packages
- Failure when package not in cache
- Working without existing lockfile
- Skipping optional dependencies not in cache
- Workspace dependencies
- Stale manifests (ignoring expiry)
- Combining with other install flags like --production
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>