Npm scripts set `TMPDIR` environment variable #4531
Comments
Run into the same issue. It's wired to set current working directory as |
woah blast from the past |
I got hit by this bug as well! |
@kumavis I don't believe this is a bug, or it is at least the intended behavior:
|
interesting... |
only you can |
Or, you know, I can do it. Closing as behaving as intended. If this is causing problems for your build scripts, @kumavis, you can explicitly set |
forgot to mention: keep being awesome |
Will do! |
And Inside Docker, maybe this is the issue. But when script is run directly ( |
Wow, I'm seeing the same as @erykpiast - it actually blows away my environment's setting to replace the value with the CWD. Crazy. |
Just ran into this. Also in a docker container. Pretty confused. |
No words. I spend hours to make npm working. A lot of strange bugs. And all closed as intended or as won't fix. No words. But no way to get rid of npm :( |
It doesn't work. Doesn't work. NPM must work as node does, without any magic. Damn. |
@othiym23 Please re-open. The scripts runs as intended if you run it with node itself. |
To not change the value of the environment variable -- if (!npm.config.get('unsafe-perm')) env.TMPDIR = null
++ if (!npm.config.get('unsafe-perm')) npm.config.set('tmp', wd) |
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
For Docker, we can run with |
@paulodiovani Just set |
|
Set the default cache directory as the [common cache directory](https://github.com/avajs/find-cache-dir), `./node_modules/.cache/babel-loader`. Previously, when `cacheDirectory` was set to `true`, babel-loader tried to use the operating system's temporary directory as a cache directory. However, when running npm scripts as the root user, [npm overrides the TMPDIR environment variable](npm/npm#4531). This caused the cache files to be created in the project folder itself, for example when using Docker: facebook/create-react-app#483.
npm sets TMPDIR to the cwd if running as the root user, per npm/npm#4531, which is the, ahem, root cause of the test failure in run-path-missage-package.js. There are two workarounds: invoke npm with --unsafe-perm or run it as a different user. This commit attempts to do the latter.
npm sets TMPDIR to the cwd if running as the root user, per npm/npm#4531, which is the, ahem, root cause of the test failure in run-path-missage-package.js. There are two workarounds: invoke npm with --unsafe-perm or run it as a different user. This commit attempts to do the latter.
I found this bug while using
os.tmpdir()
When executing as root on OSX, there is no explicit tmpdir provided from the environment variables. When using
os.tmpdir()
, node correctly falls back to '/tmp'. However when running scripts via npm, it seems that the environment variableTMPDIR
is set to the cwd when undefined. This causesos.tmpdir()
to incorrectly return the cwd as the tmp directory.in my
package.json
another test, in my
package.json
my system (osx 10.9.1):
The text was updated successfully, but these errors were encountered: