Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pm/global-cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Bun stores every package downloaded from the registry in a global cache at `~/.b
# the directory to use for the cache
dir = "~/.bun/install/cache"

# when true, don't load from the global cache.
# Bun may still write to node_modules/.cache
# when true, disable both the global cache and the npm manifest cache
# (same as `install.cache = false`)
disable = false

# when true, always resolve the latest versions from the registry
Expand Down
4 changes: 2 additions & 2 deletions docs/runtime/bunfig.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ To configure the cache behavior:
# the directory to use for the cache
dir = "~/.bun/install/cache"

# when true, don't load from the global cache.
# Bun may still write to node_modules/.cache
# when true, disable both the global cache and the npm manifest cache
# (same as `install.cache = false`)
disable = false

# when true, always resolve the latest versions from the registry
Expand Down
20 changes: 10 additions & 10 deletions src/install/PackageManager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2029,11 +2029,6 @@ pub fn init(
{
// SAFETY: as above; scoped reborrow for the options/manifest-cache block.
let manager = unsafe { &mut *manager_ptr };
if !manager.options.enable.cache() {
manager.options.enable.set_manifest_cache(false);
manager.options.enable.set_manifest_cache_control(false);
}

if let Some(manifest_cache) = env.get(b"BUN_MANIFEST_CACHE") {
if manifest_cache == b"1" {
manager.options.enable.set_manifest_cache(true);
Expand All @@ -2057,6 +2052,11 @@ pub fn init(
subcommand,
)?;

if !manager.options.enable.cache() {
manager.options.enable.set_manifest_cache(false);
manager.options.enable.set_manifest_cache_control(false);
}

if let Some(config) = ctx.install.as_deref_mut() {
if let Some(p) = config.public_hoist_pattern.take() {
manager.options.public_hoist_pattern = Some(p);
Expand Down Expand Up @@ -2414,11 +2414,6 @@ pub(crate) fn init_with_runtime_once(
manager.options.log_level = package_manager_options::LogLevel::DefaultNoProgress;
}

if !manager.options.enable.cache() {
manager.options.enable.set_manifest_cache(false);
manager.options.enable.set_manifest_cache_control(false);
}

if let Some(manifest_cache) = env.get(b"BUN_MANIFEST_CACHE") {
if manifest_cache == b"1" {
manager.options.enable.set_manifest_cache(true);
Expand All @@ -2444,6 +2439,11 @@ pub(crate) fn init_with_runtime_once(
}
}

if !manager.options.enable.cache() {
manager.options.enable.set_manifest_cache(false);
manager.options.enable.set_manifest_cache_control(false);
}

manager.timestamp_for_manifest_cache_control =
((u64::try_from(bun_core::time::timestamp().max(0)).expect("int cast")) as u32)
// When using "bun install", we check for updates with a 300 second cache.
Expand Down
Loading
Loading