npm_lazy icon indicating copy to clipboard operation
npm_lazy copied to clipboard

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

Open PAStheLoD opened this issue 10 years ago • 7 comments

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

PAStheLoD avatar Sep 10 '15 04:09 PAStheLoD

Is this still the case?

jpaulin avatar Jan 20 '16 07:01 jpaulin

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.

PAStheLoD avatar Jan 20 '16 08:01 PAStheLoD

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 :-)

jpaulin avatar Jan 20 '16 09:01 jpaulin

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 :)

PAStheLoD avatar Jan 20 '16 11:01 PAStheLoD

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

mixu avatar Jan 21 '16 04:01 mixu

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

jpaulin avatar Jan 22 '16 19:01 jpaulin

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?

framp avatar Mar 14 '16 18:03 framp