Homebridge: Permissions issue with Raspberry Pi installation

Created on 10 Dec 2017  路  5Comments  路  Source: homebridge/homebridge

I seem to be having a permissions issue with a Raspberry Pi installation. I'm using a Raspberry Pi Model 3 with the NOOBS OS installed. I am a noob on Raspberry Pi - I have been running homebridge on my Macintosh for some time, and I'm trying to consolidate some server functions on to a Raspberry Pi.

Following the instructions for installation, I did need to use the "--unsafe-perm" flags to get all the necessary files to install. Homebridge was installed into ~/.homebridge without the standard config file. I was able to add a config file and get homebridge to run.

Now I'm trying to install plugins, and getting some unusual behavior, which I expect is due to a permissions problem. Here's an example:

pi@raspberrypi:/ $ sudo npm install -g git+https://github.com/luisiam/homebridge-liftmaster2.git
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone -q https://github.com/luisiam/homebridge-liftmaster2.git /root/.npm/_cacache/tmp/git-clone-18c6dc1e
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-18c6dc1e': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-12-10T19_09_41_737Z-debug.log

I do not have root permission (which I suspect is a safety feature that might need to be disabled) to get to the log.

Appreciate any assistance!

Steve

Versions

  • Homebridge: 5.6.0
  • Node: 8.9.1
  • OS: Raspberry Pi
stale

Most helpful comment

Figured it out. Needed to NOT run as sudo (which tried to put the files into the root user), but instead change the owner of the node_modules folder from root to my username. Not sure why node_modules was installed as owned by root, but everything seems to be working now. Perhaps adding this info to the Raspberry Pi installation wiki would be helpful to someone else.

All 5 comments

add "--unsafe" at the end of the "npm" line.

No change.

pi@raspberrypi:~ $ sudo npm install -g git+https://github.com/luisiam/homebridge-liftmaster2.git --unsafe
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone -q https://github.com/luisiam/homebridge-liftmaster2.git /root/.npm/_cacache/tmp/git-clone-82b4dabd
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-82b4dabd': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-12-18T01_52_44_430Z-debug.log

Figured it out. Needed to NOT run as sudo (which tried to put the files into the root user), but instead change the owner of the node_modules folder from root to my username. Not sure why node_modules was installed as owned by root, but everything seems to be working now. Perhaps adding this info to the Raspberry Pi installation wiki would be helpful to someone else.

@BuckarooToo You a genius. If you cloned your repo using sudo or created your directory using sudo, then its owned by root and npm install will try to install packages to the root user.

This issue has been automatically marked as stale because it has not had recent activity, and will be closed if no further activity occurs. If this issue was overlooked, forgotten, or should remain open for any other reason, please reply here to call attention to it and remove the stale status. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings