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

node-gyp requires home to specified by environment variables #18

Closed
sam-github opened this issue Aug 20, 2014 · 9 comments
Closed

node-gyp requires home to specified by environment variables #18

sam-github opened this issue Aug 20, 2014 · 9 comments

Comments

@sam-github
Copy link
Contributor

From Lee Driscoll:

When deploying through strong-pm, the npm rebuild phase returns the following error:

Error: node-gyp requires that the user's home directory is specified in either of the environmental variables HOME or USERPROFILE

Googling that message shows people having this problem across various systems and fixing it by setting $HOME explicitly at the start of their script.

Using the .env file doesn't work I believe as that isn't read until the "start" phase

@sam-github
Copy link
Contributor Author

@rmg , I'd think upstart would set this, but maybe we need to set ourselves?

@ lee, did you use pm-install to install? OS distribution and upstart version?

@rmg
Copy link
Member

rmg commented Aug 20, 2014

@sam-github we already explicitly set it in the Upstart job for this very reason.

@sam-github
Copy link
Contributor Author

Hm... Lee, did you write a systemd job yourself? Or you own job? How are you arranging to start strong-pm?

@innerdaze
Copy link

@sam-github I'm using a systemd job created as a result of https://groups.google.com/forum/#!topic/strongloop/4iNqnrcM6nA

[Unit]
Description=Strongloop Process Manager - Ibcos API Server - Production
After=network.target

[Service]
ExecStart=/usr/local/bin/slc pm -l 7779 -b /home/dev/strong-pm/ibcos-api-server-production
Restart=always

[Install]
WantedBy=multi-user.target

@sam-github
Copy link
Contributor Author

@lsdriscoll, OK, so setting HOME in your systemd job will fix this.

@rmg opinion on whether strong-pm should set HOME/the-windows-equivalent to it's CWD or it's BASE if it finds it not set? Given that its not clear what HOME should be if its not set, I'm not sure it should make a choice.

@rmg
Copy link
Member

rmg commented Aug 21, 2014

@lsdriscoll sorry I didn't notice the missing $HOME at the time.

Assuming dev is the user and /home/dev is their $HOME, your systemd unit should look like:

[Unit]
Description=Strongloop Process Manager - Ibcos API Server - Production
After=network.target

[Service]
ExecStart=/usr/local/bin/slc pm -l 7779 -b /home/dev/strong-pm/ibcos-api-server-production
Restart=always
User=dev
Environment=HOME=/home/dev

[Install]
WantedBy=multi-user.target

@rmg
Copy link
Member

rmg commented Aug 21, 2014

@sam-github node-gyp only needs it to store downloaded headers to build against (which I think is actually unnecessary: nodejs/node-gyp#492). Come to think of it, I'm not sure where npm is storing its cache if $HOME isn't set.

We could look up the HOME of the uid being run under as a fallback (on OS X and Linux, at least). Does it seem likely that a user would intentionally unset $HOME?

@sam-github
Copy link
Contributor Author

@lsdriscoll can you confirm the systemd fix works for you and we'll close issue? When we support systemd, we'll make sure this works out of the box.

@innerdaze
Copy link

@sam-github That works perfectly 👍

@rmg rmg closed this as completed Aug 22, 2014
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

3 participants