mixu / npm_lazy

A lazy local cache for NPM to make your local deploys faster
http://mixu.net/npm_lazy/
Other
753 stars 72 forks source link

Fails to start if $HOME is not set (which happens if run under upstart) #51

Open PAStheLoD opened 9 years ago

PAStheLoD commented 9 years ago

In config.js path.normalize gets an undefined and the program aborts if HOME is not set.

jpaulin commented 8 years ago

Is this still the case?

PAStheLoD commented 8 years ago

Haven't tried it since. I guess it's best to close this issue and if someone encounters it again they can just reopen it.

jpaulin commented 8 years ago

The logic goes like: If we are running on win32, take USERPROFILE (environment variable) otherwise take HOME. If HOME unset, the expression evaluates to undefined.

What's the ballpark role of upstart Linux? Just out of curiosity :-)

PAStheLoD commented 8 years ago

Upstart is the user space process manager used by Ubuntu, it's the "init system", as it starts other user space stuff (udev, dhcpd, cron, wpa-supplicant, ssh, lightdm, which in turn start X and a desktop environment, such as KDE, GNOME, Xfce), and as the process with process id 1, it's responsible for reaping zombies. The usual stuff :)

Ubuntu is moving to systemd (new init system, big flame wars, all the fun you can imagine!), but I don't know whether $HOME will be defined there by default for services.

So, if npm_lazy hard-depends on HOME in the environment, then it should check for it and complain loudly if it cannot find it :)

mixu commented 8 years ago

Happy to accept a PR to make this better - perhaps via https://www.npmjs.com/package/home-path ?

jpaulin commented 8 years ago

Interesting idea! Let's see what's coming up from the cauldron. :-)

framp commented 8 years ago

The same issue involves systemd.

[Unit]
Description=NPM Lazy Cache
Requires=network.target
After=network.target

[Service]
#Environment=HOME=/home/framp
ExecStart=/usr/bin/npm_lazy --config /etc/npm_lazy.config.js
Restart=always

[Install]
WantedBy=multi-user.target

A workaround is simply to set HOME but the proper solution would be to fix config.js.

Maybe there is a way not to require HOME? Maybe using cwd if HOME is not set?