-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShellJSInternalError: ENOENT: no such file or directory, open '/tmp/shelljs_...' #1024
Comments
What is |
It's part of the
|
As far as I'm aware, this should work fine. Does the node script have permission to create the |
Yes, I am running exec inside an express http handler. It usually works the first time after the server starts but on subsequent requests I get this error. Restarting the server makes it work again (for the next request). |
We keep running into this as well, have not pinpointed exactly how it happens, though it's usually happening when package.lock is changed, it might be related to importing a package that also has shelljs as a dependency but still trying to confirm that. |
It sounds like it might be useful to see the output of |
|
Ah, well that rules out the hypothesis of other projects importing shelljs 😜 Maybe something is tampering with global state we rely on? One thing which comes to mind is you could check the return value of Line 33 in 71085db
|
No, it looks like the
Is it expected that the filename changes across invocations? |
In case helpful:
|
Looks like those folders are only writable by If I remember correctly, it's not always easy to distinguish between "file doesn't exist" and "I don't have permission to access the file." So By the way, what version of Ubuntu are you all using? Maybe there's a policy change in a recent Ubuntu version. |
I didn't think it was a permissions issue because shelljs was successfully able to create those files in the first place. Again, the confusing thing going on here is that exec is working on the first invocation (the first time I hit my endpoint) but seems to fail in subsequent invocations (all in the same process). When I get the ENOENT error, it appears to me that the file shelljs is trying to find simply does not exist (rather than exists but the process can't read it). |
It would still help to know (1) which Ubuntu version and (2) are you running your app as |
Ubuntu version 18.04, and yes the process is running as root |
also on ubuntu (will check the version tomorrow), but not as root. |
For folks who can repro? Would you mind cloning the ShellJS GitHub project, running If that doesn't repro, could someone throw together a minimal repro project for me to debug on my machine? |
Have a repro on a machine right now
trying to run your test suite but cant seem to figure how it works, did yarn install (took ages) and have all tests fail with
|
We just use the standard npm workflow (i.e., That specific error message looks like the code isn't being transpiled. |
We encountered this issue as well. I've created a minimal repo for reproduction: https://github.com/politics-rewired/shelljs-repro. This is written in TS because that's what we use, but happens in plain JS as well. The basic workflow is:
The problem was fixed for us by |
Hmm, I get a different error when I try similar code locally. I noticed that
Also, I noticed that subsequent |
Any updates/workarounds on this issue? I'm running into it on my 12.22.1 Node environment running on AWS EC2. The command in specific I'm tryin to execute is |
I ran the tests against ad91197. All tests passed: $ npm run test
> shelljs@0.8.3 test /home/pi/dev/git/shelljs
> ava test/*.js
⠦ which › basic usage
580 tests passed
6 tests skipped
> shelljs@0.8.3 posttest /home/pi/dev/git/shelljs
> npm run lint
> shelljs@0.8.3 lint /home/pi/dev/git/shelljs
> eslint .
Executing the following failed on my raspberrypi: const shell = require('shelljs');
shell.env.NODE_OPTIONS = '--max_old_space_size=4096';
shell.exec('ls -al'); $ node index.js
<--- Last few GCs --->
[8259:0x3e7f5d8] 166 ms: Mark-sweep 1.0 (3.5) -> 1.0 (3.5) MB, 6.8 / 0.0 ms (average mu = 0.678, current mu = 0.122) allocation failure GC in old space requested
[8259:0x3e7f5d8] 171 ms: Mark-sweep 1.0 (3.5) -> 1.0 (2.5) MB, 3.3 / 0.0 ms (average mu = 0.593, current mu = 0.217) last resort GC in old space requested
[8259:0x3e7f5d8] 175 ms: Mark-sweep 1.0 (2.5) -> 0.9 (2.5) MB, 4.1 / 0.0 ms (average mu = 0.438, current mu = 0.010) last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0xee5d00]
1: StubFrame [pc: 0xe5e20c]
Security context: 0x58b4ea35 <JSObject>
2: new constructor(aka Module) [0x24e1e2b5] [internal/modules/cjs/loader.js:142] [bytecode=0x24e31231 offset=34](this=0x24e3956d <Module map = 0x4dba48ed>,0x24e2e485 <String[#68]: /home/pi/dev/git/shelljs-test/node_modules/shelljs/src/exec-child.js>,0x5ebc00dd <null>)
3: ConstructFrame [pc: 0xe585ac]
4: StubFrame [pc: 0xf548...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/common.js:399
throw e;
^
Error [ShellJSInternalError]: ENOENT: no such file or directory, open '/tmp/shelljs_88c795440bd0ebc44834'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at execSync (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/exec.js:89:17)
at Object._exec (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/exec.js:205:12)
at Object.exec (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/common.js:335:23)
at Object.<anonymous> (/home/pi/dev/git/shelljs-test/index.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/tmp/shelljs_88c795440bd0ebc44834'
} It looked like it was some Node.js memory issue in my case, the reserved heap space was greater than the available. The Some env info: $ uname -a
Linux raspberrypi 4.19.118-v7l+ #1311 SMP Mon Apr 27 14:26:42 BST 2020 armv7l GNU/Linux $ free
total used free shared buff/cache available
Mem: 3999744 1871080 559256 360888 1569408 1615736
Swap: 102396 256 102140 node -v && npm -v
v12.22.8
6.14.15 After specifying a valid heap size, I could run my module: const shell = require('shelljs');
shell.env.NODE_OPTIONS = '--max_old_space_size=1024';
shell.exec('ls -al'); $ node index.js
total 28
drwxr-xr-x 3 pi pi 4096 Dec 27 11:46 .
drwxr-xr-x 6 pi pi 4096 Dec 27 11:56 ..
-rw-r--r-- 1 pi pi 109 Dec 27 12:41 index.js
drwxr-xr-x 22 pi pi 4096 Dec 27 11:46 node_modules
-rw-r--r-- 1 pi pi 274 Dec 27 11:46 package.json
-rw-r--r-- 1 pi pi 5314 Dec 27 11:46 package-lock.json Maybe Update: if I use any invalid heap size setting,
const shell = require('shelljs');
shell.env.NODE_OPTIONS = '--max_old_space_size=alma';
shell.exec('echo'); $ node index.js
Error: illegal value for flag --max_old_space_size=alma of type size_t
Try --help for options
/home/pi/.config/nvm/versions/node/v12.22.8/bin/node: bad option: --max_old_space_size=alma
/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/common.js:399
throw e;
^
Error [ShellJSInternalError]: ENOENT: no such file or directory, open '/tmp/shelljs_cb392bd3b0c9bf1b07d9'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at execSync (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/exec.js:89:17)
at Object._exec (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/exec.js:205:12)
at Object.exec (/home/pi/dev/git/shelljs-test/node_modules/shelljs/src/common.js:335:23)
at Object.<anonymous> (/home/pi/dev/git/shelljs-test/index.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/tmp/shelljs_cb392bd3b0c9bf1b07d9'
} |
I tried this on Ubuntu (node v12.22.8 installed through nvm) but I get a different error:
I could try on a raspberry pi (raspbian/raspberry pi OS), but I'm curious why that would be different. Are other folks hitting this error on other systems? |
With Node 16+ and Heap size exceeds the available:
Invalid heap size:
|
Hi there! I've been following this thread, is there any recommended course of action for resolving these kinds of errors? I am experiencing a very similar kind of ShellJS ENOENT error as what has been reported in this issue for the Docusaurus project: |
I'm running into this issue as well for a long lived process within a Docker container. It seems to fix itself after a restart. I suspect the temp directory might be drifting after some event, but I don't see a definitive reason. My docker container is running |
Node version (or tell us if you're using electron or some other framework):
v14.8.0
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.4
Operating system:
Ubuntu
Description of the bug:
Example ShellJS command to reproduce the error:
The text was updated successfully, but these errors were encountered: