Repository navigation
Milestone
Description
Bug report form
- I have done a basic search of the issue tracker to find any existing issues that are similar.
- I have checked that my version is at least the latest stable release available via my installation method.
Describe the bug
Running rm -rf node_modules in Nushell after bun i --frozen-lockfile fails on the first attempt with nu::shell::io::directory_not_empty (Directory not empty (os error 66)), leaving node_modules intact (deleted: false), and then succeeds when run a second time (deleted: true).
- Waiting 5–10 seconds after
bun i --frozen-lockfiledoes not change the behavior (it does not appear to be a short-lived I/O timing race). - Reproduces even when starting Nushell with
--no-config-file. - Does not occur with external
/bin/rm -rfor^rm -rf. - Did not reproduce on a minimal
bun initproject with only@types/bunindevDependencies, suggesting it may depend on directory size/depth/file count or specific entries in a largernode_modulestree.
How to reproduce
- Start Nushell (even with
nu --no-config-file) on macOS (aarch64-apple-darwin). - In a project with a
package.jsonlike the following and runbun i --frozen-lockfile:
{
"name": "project-name",
"version": "0.4.0",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"gen-tree": "nu scripts/generate-directory-tree.nu",
"generate": "nuxt generate",
"postinstall": "nuxt prepare",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier": "prettier --write .",
"preview": "nuxt preview",
"typecheck": "vue-tsc -b --noEmit"
},
"dependencies": {
"@tailwindcss/vite": "4.3.5",
"canvas-confetti": "1.9.4",
"gsap": "3.15.1",
"tailwindcss": "4.3.5"
},
"devDependencies": {
"@commitlint/cli": "21.2.4",
"@commitlint/config-conventional": "21.2.4",
"@nuxt/eslint": "1.17.0",
"@types/canvas-confetti": "1.9.0",
"eslint": "10.15.0",
"eslint-plugin-perfectionist": "5.14.0",
"eslint-plugin-tailwindcss": "4.4.0",
"nuxt": "4.6.4",
"prettier": "3.10.1",
"typescript": "6.0.3",
"vue-tsc": "3.3.14",
"wrangler": "4.165.0"
}
}- Run:
rm -rf node_modules
bun i --frozen-lockfile
rm -rfv node_modules- Observe that the first
rm -rfv node_modulesreturnsdeleted: falsewithI/O error(os error 66: Directory not empty). - Run
rm -rfv node_modulesa second time immediately after:
rm -rfv node_modules- Observe that the second run succeeds with
deleted: true.
Expected behavior
The first rm -rf node_modules should remove the node_modules directory and its contents without failing with Directory not empty (os error 66).
Configuration
| key | value |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| version | 0.116.1 |
| major | 0 |
| minor | 116 |
| patch | 1 |
| branch | |
| commit_hash | |
| build_os | macos-aarch64 |
| build_target | aarch64-apple-darwin |
| rust_version | rustc 1.99.0 (b940084d7 2026-09-28) (Homebrew) |
| cargo_version | cargo 1.99.0 (5f94df478 2026-08-27) (Homebrew) |
| build_time | 2026-10-04 14:31:48 +00:00 |
| build_rust_channel | release |
| allocator | standard |
| features | dap, default, lsp, mcp, network, plugin, rustls-tls, sqlite, trash-support |
| installed_plugins | |
| experimental_options | example=false, dc-glob=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=false, cell-path-types=false |
Additional environment details:
- macOS:
27.2.1(26B131) - Bun:
1.4.4
Activity
fdncred commentedon Nov 19, 2026
I can't reproduce on 0.117.1 latest main branch. Can you try it out and see if it fixes the problems?
cotone-dev commentedon Nov 20, 2026
Thank you for checking this!
First, I apologize for submitting the initial report on an outdated version (
0.116.1) despite checking the box in the template.I have updated Nushell to
0.117.0(the latest version available via Homebrew and on the GitHub Releases page) and tested it again, but the issue still reproduces with the exact same behavior.Regarding
0.117.1, since I couldn't find a release or tag for it, I assume you are referring to the current development state on themainbranch. Building from source is a bit difficult for me, and since this isn't an urgent issue, I'd prefer to wait for the official0.117.1release (via Homebrew) and test it again then.I'll leave this issue open for now until I can verify it on
0.117.1, unless you prefer to close it earlier. Thanks again for your help!fdncred commentedon Nov 20, 2026
you can get nightlies here https://github.com/nushell/nightly/releases
cotone-dev commentedon Nov 21, 2026
Thanks for pointing me to the nightly releases!
I tested this on
0.117.1-nightly.7, and it still reproduces in my original project directory:nu --no-config-file.rm -rf node_modulesandrm -rfv node_modules.os error 66(Directory not empty), and runningrm -rf node_modulesa second time immediately afterward succeeds.Error output from
rm -rf node_modules:Two additional findings that may help explain why you couldn't reproduce this:
node_modulesis partially deleted on the first attempt (rather than left completely intact as I initially assumed):rm -rf node_modules:41,026entries (^find node_modules | ^wc -l)rm -rf:12,399entries remainingls -la node_modulesafter the failure shows253subdirectories remaining (from.cachethroughzip-stream), while earlier entries (such as.bin/.bun) appear to have been removed.package.jsonandbun.lock:package.jsonandbun.lockinto/tmp/nu-rm-reproand~/projects/nu-rm-repro, and ranbun i --frozen-lockfile.^find node_modules | ^wc -lgave the exact same count (41,026) in all three directories, yetrm -rf node_modulessucceeded on the first attempt in both/tmp/nu-rm-reproand~/projects/nu-rm-repro.nuxt.config.ts, or another background process monitoring/accessing that directory).Please let me know if there are any specific checks or logs I can collect from the failing directory to help track this down!
version | transpose key value | to md --prettyon nightlyfdncred commentedon Nov 22, 2026
please try #19637 and see if it helps
cotone-dev commentedon Nov 23, 2026
Thank you for the quick fix!
I tested PR #19637 on macOS, and it completely resolves the issue for me:
rm -rf node_modulesandbun i --frozen-lockfilecycle multiple times on the repository fromrm -rfon a largenode_modulesdirectory fails on the first attempt withos error 66(Directory not empty) and succeeds on the second attempt on macOS #19599, and every attempt succeeded on the first try withoutos error 66.node_modulesdirectory, and it succeeded cleanly every time there as well.Thanks again for investigating this and putting together the fix!
fix(rm): retry `rm -r` when a directory is left not empty (nushell#19637