Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

While running as root .gz files gets created on working directory #545

Closed
drFabio opened this issue Jul 1, 2016 · 5 comments
Closed

While running as root .gz files gets created on working directory #545

drFabio opened this issue Jul 1, 2016 · 5 comments
Assignees
Labels

Comments

@drFabio
Copy link
Contributor

drFabio commented Jul 1, 2016

When running phenomic as root a bunch of .gz files intended for cache get's created on the working directory.

This is caused by the os.tmpdir() and process.env.TMPDIR pointing to the working dir and not /tmp/ as expected. This is similar to this webpack issue and caused by the same reasons

On this issue from npm it says it is related to this line on npm and relates the switch to this npm configuration.

So running trhough npm as root changes the tmp dir.

So for example this script:

console.log('Env: '+process.env.TMPDIR);
console.log('By os:'+require('os').tmpdir());

As root (either locally or on container):

Env: CURRENT DIR
By os: CURRENT DIR

On container directly as root (node script.js):

Env: undefined
By os:/tmp

running locally directly (non root):

Env: undefined
By os:/tmp

locally trhough npm gives (non root):

Env: /tmp
By os:/tmp

I realize this is the expected behaviour by NPM folks but is a pretty specific caveat and one that will always happen on docker.

I suggest either asking for the tmp directory on the setup script and configuring unsafe-perm or the env var , or put a warning on the script before start if tmp dir is equal to working dir , or even a simple warning somewhere on the site to people be aware of the caveat.

@MoOx
Copy link
Owner

MoOx commented Jul 1, 2016

The thing is: we don't use tmpdir() or TMPDIR in our codebase. So not sure if we should handle this.

Asking for something during the setup might seems overkill (for most use case).
Anyway, if nobody is open to handle that (pretty sure npm won't be open for a change, nor webpack) we might do something like a warning (at least).

Can you check if disabling babel cacheDirectory fix this problem? It seems it might be the culprit (in this case we can specify a specific folder - so fix this issue ourself).

@MoOx MoOx added the bug label Jul 1, 2016
@drFabio
Copy link
Contributor Author

drFabio commented Jul 2, 2016

Setting cache_directory to false on webpack,config.babel.js did solve the problem.
Probably changing the cache directory for webpack to /tmp would solve it as well.

@thangngoc89
Copy link
Contributor

I sent a PR to create-react-app to fix this issue here facebook/create-react-app#620

Poke @MoOx should I do the same here?

@thangngoc89 thangngoc89 self-assigned this Sep 14, 2016
@thangngoc89
Copy link
Contributor

I have a local wip but it uses Jest.

Waiting on #744

@MoOx MoOx removed the wip label Nov 9, 2016
@MoOx
Copy link
Owner

MoOx commented Nov 9, 2016

babel-loader now handle this.

@MoOx MoOx closed this as completed Nov 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants