Skip to content
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

Gulp - Unable to cache a config file for v8flags #22

Closed
huston8 opened this issue Jun 11, 2015 · 36 comments
Closed

Gulp - Unable to cache a config file for v8flags #22

huston8 opened this issue Jun 11, 2015 · 36 comments

Comments

@huston8
Copy link

huston8 commented Jun 11, 2015

Hello,

I am using a CMS to publish Gulp+less files. The gulp needs to run locally on the CMS server (.\node_modules.bin\gulp). This works fine if I run via a command prompt by navigating to \node_modules.bin. Please note that Gulp is not installed globally on server.

However when I am trying to run gulp with help of C# template (CMD + arguements = "/c CD node_modules/.bin/ & gulp") I get the below error.

Engine: Error in Engine.Transform
Engine: Error in Engine.Transform
D:\t20150611182707811\node_modules\gulp\node_modules\liftoff\index.js:182
throw err;
^
Error: EPERM, open 'C:\Windows\system32\config\systemprofile.v8flags.3.28.73.W655$.json'

Unable to cache a config file for v8flags to a your home directory
or a temporary folder. To fix this problem, please correct your
environment by setting HOME=/path/to/home or TEMP=/path/to/temp.
NOTE: the user running this must be able to access provided path.
If all else fails, please open an issue here:
http://github.com/tkellen/js-v8flags

Unable to cache a config file for v8flags to a your home directory
or a temporary folder. To fix this problem, please correct your
environment by setting HOME=/path/to/home or TEMP=/path/to/temp.
NOTE: the user running this must be able to access provided path.
If all else fails, please open an issue here:
http://github.com/tkellen/js-v8flags
at Error (native)

Liftoff Version is v2.1.0:

@odensc
Copy link
Contributor

odensc commented Jun 11, 2015

This is a permission error. It looks like the HOME environment variable is set to system32\config, and the user probably doesn't have permission to write to there.

@huston8
Copy link
Author

huston8 commented Jun 12, 2015

I dont see the home variable is set on server. what can be other issues?

@odensc
Copy link
Contributor

odensc commented Jun 12, 2015

Open the node REPL with node, and type in the following commands:

console.log(env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || env.HOME || null);
console.log(os.tmpdir());

And reply with the output.

@huston8
Copy link
Author

huston8 commented Jun 12, 2015

The strange thing is, this works with command prompt, but not when I run a command prompt using C#.

Here is the output:

console.log(env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || env.HOME || null);
ReferenceError: env is not defined
at repl:1:13
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface. (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)

console.log(os.tmpdir());
C:\Users\SDL_W6~1\AppData\Local\Temp\2
undefined

@odensc
Copy link
Contributor

odensc commented Jun 12, 2015

Oh sorry, try:

console.log(process.env.USERPROFILE);
console.log(process.env.HOMEPATH);
console.log(process.env.HOMEDRIVE);
console.log(process.env.HOME);

@huston8
Copy link
Author

huston8 commented Jun 12, 2015

Here you go:

console.log(os.tmpdir());
C:\Users\SDL_W6~1\AppData\Local\Temp\2
undefined

console.log(process.env.USERPROFILE);
C:\Users\SDL_W655_W662
undefined

console.log(process.env.HOMEPATH);
\Users\SDL_W655_W662
undefined

console.log(process.env.HOMEDRIVE);
C:
undefined

console.log(process.env.HOME);
undefined
undefined

@odensc
Copy link
Contributor

odensc commented Jun 12, 2015

The variables seem to be fine in the CLI. Does this "C# template" change users? You could try putting the commands I listed in a .js file, and then run it through the template to see what it outputs.

@huston8
Copy link
Author

huston8 commented Jun 12, 2015

I am not very sure how can i do this as we have a class library project. However looking at the code it does not change the users.

@odensc
Copy link
Contributor

odensc commented Jun 12, 2015

Well, it's doing something with the environment variables. If you can do this in the code, try setting the environment variable HOME to a place where the config file can be written before gulp is run.

@huston8
Copy link
Author

huston8 commented Jun 12, 2015

I came across this line of code :

string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

and it returns "NT AUTHORITY\NETWORK SERVICE".

This might be the issue?

@odensc
Copy link
Contributor

odensc commented Jun 12, 2015

Yes that's probably the issue. Is there a way to change the user to what it should be?

@huston8
Copy link
Author

huston8 commented Jun 13, 2015

Thats indeed the issue. As a workaround I manually gave read/write permissions to 'Network Service' user on directory 'C:\Windows\system32\config'. I understand this shall not be a permanent solution.

All tridion templates run via impersonated user 'Network Service' hence it will be difficult for us to change that. Is there any way the 'C:\Windows\system32\config' directory can be replaced by another one?

@odensc
Copy link
Contributor

odensc commented Jun 13, 2015

Yes, you can set the USERPROFILE variable to the path you want it to save to, as long as the template doesn't override it.

@huston8
Copy link
Author

huston8 commented Jun 14, 2015

Thanks Oden. Sorry, but I am new to this gulp and all. Could you please advise how can I set this variable?
Do you mean to say that this should be set in environment variables of server?

@odensc
Copy link
Contributor

odensc commented Jun 14, 2015

Yes, the environment variables of the server. Though, the template may override it.

@huston8
Copy link
Author

huston8 commented Jun 15, 2015

I added Something like this to System Variables:
variable Name : USERPROFILE
Variable Value : D:\gulp-test\

But this isn't working. I dont think the template overrides either.....

@artyfarty
Copy link

FFS.

Our builds suddenly failed because of that cryptic .cache error. Simply created folder myself and it worked. Why does it not create that folder itself?

Now why change this in minor version (that is not locked in gulp for some stupid reason)?

@tkellen
Copy link

tkellen commented Jun 15, 2015

@artyfarty Sorry for the regression. I'll release a patch that reverts this.

@phated What do you think about just throwing an annoying warning in gulp if this file can't be cached, and allowing it to just run anyway? For CI servers (where this seems to be the most error prone) the performance hit of having to invoke node to get the v8 flag listing should be meaningless.

@phated
Copy link
Member

phated commented Jun 15, 2015

@tkellen 👍 on that idea. any way to bubble that up to a liftoff event so gulp can format the warning nicely?

@huston8
Copy link
Author

huston8 commented Jul 30, 2015

Hello....any update on this one....affecting now on another server :(

@phated
Copy link
Member

phated commented Jul 30, 2015

@huston8 all of us are busy currently with work and other life things, sorry. If you can, please send a patch.

@raffus
Copy link

raffus commented Aug 31, 2015

I wonder how can a collaborator give such "contribution".

PHATED, instead of loosing your time writing this crap please use it to cooperate.
Lots of people having this issue, including me.

Any patch available or new release in a near future?

This is the output:

/home/virtual/com/htdocs/drag-drop/create-mail.php on line 16
string(520) "/usr/lib64/node_modules/gulp/node_modules/liftoff/index.js:182 throw err; ^ Error: EACCES, open '/.v8flags.3.28.71.19.undefined.json' Unable to cache a config file for v8flags to a your home directory or a temporary folder. To fix this problem, please correct your environment by setting HOME=/path/to/home or TEMP=/path/to/temp. NOTE: the user running this must be able to access provided path. If all else fails, please open an issue here: http://github.com/tkellen/js-v8flags at Error (native) "

@phated
Copy link
Member

phated commented Aug 31, 2015

@raffus PRs welcome

@raffus
Copy link

raffus commented Aug 31, 2015

?
I didnt mean to be rude but the community is still waiting for a solution.

@elldritch
Copy link
Contributor

👍 This issue hits me whenever I try to build with gulp on hosted servers where I don't have write permissions for $HOME.

@banerjs
Copy link

banerjs commented Dec 17, 2015

+1

Just hit this issue trying to deploy on OpenShift

@elldritch
Copy link
Contributor

@banerjs Just pushed 2.0.11 which should allow you to deploy. Can you see if this fixes your problem?

@banerjs
Copy link

banerjs commented Dec 22, 2015

Although I am now using Heroku in order to have more flexibility with my node versions (packages can sometimes be so finicky!), I just pushed to OpenShift and can confirm that I no longer see the permissions issue that caused me to post here a few days ago.

Thanks!

@elldritch
Copy link
Contributor

Awesome, closing this issue.

@victorguo
Copy link

Hi, I came across the error as following:

EXEC : error : ENOENT: no such file or directory, open 'C:\Users\SVC-ZH~1.BLD\AppData\Local\Temp.v8flags.4.6.85.31.prod\svc-zhu.uca.bld.json'

.v8flags.4.6.85.31.prod\svc-zhu.uca.bld.json is not a valid name in Windows so it fails to create the config file.

Just let you know that I am running TFS 2015 build servers...And I trigger my build remotely. I guess that is why the username turns out prod\svc-zhu.uca.bld instead of svc-zhu.uca.bld. ("prod" is the domain name)

Can someone help me out of this?

@tkellen
Copy link

tkellen commented Mar 29, 2016

Whatcha think about md5 hashing the username @phated?

@phated
Copy link
Member

phated commented Mar 29, 2016

@tkellen I'd be fine with that, I think

@phated
Copy link
Member

phated commented Mar 29, 2016

@tkellen does that break current installs?

@tkellen
Copy link

tkellen commented Mar 29, 2016

It wouldn't break current installs, it would just regen the temp file on the next run.

@victorguo
Copy link

@tkellen Sorry to be rude but any plans to make the change?

@phated
Copy link
Member

phated commented Apr 6, 2016

@victorguo all of us are completely booked. feel free to submit a PR and we can try to find time to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants