Skip to content

Switching from isolated to hoisted linker leaves the whole store behind and bun prune refuses to clean it #38912

Description

@alistair-bot

What version of Bun is running?

1.4.0-canary.1+39fb3c103

What steps can reproduce the bug?

Install with the isolated linker, then switch the project to the hoisted linker.

bun install --linker=isolated

printf '[install]\nlinker = "hoisted"\n' > bunfig.toml
bun install

bun prune

What is the expected behavior?

Switching linkers should leave node_modules containing only the new layout, or bun prune should be able to clean up the old one.

What do you see instead?

The isolated store is left behind in full. On a Next.js app with 519 packages:

isolated install:         755 MB, node_modules/.bun has 522 entries
after switch to hoisted: 1113 MB, node_modules/.bun still has 522 entries
after bun install --force: 1570 MB

The hoisted layout is correct and working — the old store is just never removed, and re-running install keeps growing the directory.

bun prune then refuses to clean it:

error: node_modules was installed with the isolated linker, but bun prune would use the hoisted linker
note: run 'bun prune --linker isolated' to prune it as-is, or 'bun install' to reinstall with the hoisted linker

Two problems with that message:

  1. node_modules was not installed with the isolated linker — it was just reinstalled with the hoisted one. The detection appears to key off the leftover .bun directory, which is exactly the garbage that needs removing.
  2. The suggested remedy, bun install to reinstall with the hoisted linker, is the step that was already run and is what produced this state.

bun prune --production fails the same way. bun install --force does not clean it either. The only fix I found is rm -rf node_modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions