Comments (19)
Hi Rubens, can you please zip/archive the contents of the directory that's causing you trouble and send it to me? (my email is on my Github profile page)
Also, can you please paste here the output of the command /bin/ls -laR
in that directory?
Thanks!
from shelljs.
Email sent with zipped dir. I cannot /bin/ls -laR
because is a Windows Server.
from shelljs.
I see this happening on windows as well. It happens a lot in git bash or cmd as well, and usually when I try the same command again it works. Does it happen if you retry the shelljs command? I'd be surprised if this is anything but Windows being Windows.
from shelljs.
It is just as you said. When it happens then just retrying it Windows-magically works.
from shelljs.
From my experience this happens when the directory I'm trying to remove is used by another process, e.g. python running a webserver from that directory.
from shelljs.
In those situations you get an EPERM
error, if I recall correctly.
from shelljs.
Actually I get rm: could not remove directory (code EBUSY)
so irrelevant to this issue. :)
from shelljs.
Interesting though, we usually get EPERM
I believe, which was confusing as hell at first when you had some process in the background somewhere. Usually running process explorer will let you figure out which process it is to kill it, but it's massively annoying. It could be something silly such as windows explorer having that folder open, or some app that you used to browse that folder three hours ago and it's still locking it. Windows is messy :(
from shelljs.
Guys I'm unable to play with this issue on Windows atm. Would love if someone would lend a hand with this issue :)
from shelljs.
You can't reproduce this issue?
from shelljs.
@rmariuzzo I don't have a Windows box atm
from shelljs.
I also facing the same issue. It seems to be causing occasionally on windows.
from shelljs.
+1 Seem to be getting the same error here on Windows occasionally. It's annoying becuase I'm running a pretty big test suite and the tests randomly fail because of this and I need to restart it every time until it eventually works.
from shelljs.
I have changed the code block at https://github.com/arturadib/shelljs/blob/master/src/rm.js#L49 with this:
var result, files;
try {
files = fs.readdirSync(dir);
result = fs.rmdirSync(dir);
} catch(e) {
common.error('could not remove directory (code '+e.code+'): ' + dir, true);
if (e.code == "ENOTEMPTY") {
common.error('files found: ' + files.join(', '));
}
And I can indeed see that there are some files left behind sometimes, randomly.
EDIT: After some more digging, this may be related to:
nodejs/node-v0.x-archive#7164
nodejs/node-v0.x-archive#3051
However, the files should be properly closed, but this is in a rapid succession of unit tests with directories being created, files written, read, then deleted by various means, both async and sync. All fingers point to a nodejs bug of some sort.
from shelljs.
I think the only way to fix this on Windows is to auto-retry. I have found a library that doing exactly this here:
https://github.com/isaacs/rimraf
from shelljs.
I made a pull request for this that auto-retries for up to 1 second on Windows. See #179. This has made it finally usable for my purposes, fixing all errors I was getting.
from shelljs.
Closing this since #179 is merged. Please reopen if this error persists
from shelljs.
For me, shx version 0.3.2 exhibits this same intermittent behavior when run from an npm script from within VSCode; when it fails, it fails immediately (no waiting for up to 1 second). It would appear that the changes from #179 may have been lost.
from shelljs.
I still see the changes:
Lines 53 to 78 in 4e38240
I don't know enough about this problem to know if the bug still exists though.
from shelljs.
Related Issues (20)
- Sdtout is empty if using another shell
- Using exec does not terminate the command process HOT 1
- Codecov broken on CI
- Shell.exec() freezes HOT 6
- Feature request (cp): -v flag for verbose output HOT 3
- Feature request (true, false) HOT 1
- test-with-coverage is broken on node v16 HOT 1
- `cd.js` swallows the initial error HOT 1
- "TypeError: common.register is not a function" under node v20.6.0 HOT 13
- GitHub actions dropping support for node < 16
- Exec failure on Node 21 HOT 1
- In mv command, there should be en error if destination directory not present. HOT 1
- shell.exec(`mv a/m.js b/`) cannot return error stdout HOT 2
- Latest shelljs type definitions have errors HOT 1
- Vulnerability in shelljs dependency: CWE-772: Missing Release of Resource after Effective Lifetime HOT 4
- shelljs.exec or child_process.exec not executing HOT 2
- Shelljs EXEC does not work when running a pre-compiled binary application HOT 4
- Attempted to import the Node standard library module "fs" HOT 1
- A problem with cd outside the project HOT 3
- `exec-child.js` module not found, when running `shell.exec()` on Next.js Server Actions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shelljs.