I was wondering how to change the gpio directory for the node.js pi-gpio library. Whenever I try to run the script to change the pin it returns this error:

"Error when trying to open pin 40

gpio-admin: failed to change group ownership of /sys/devices/virtual/gpio/gpio21/direction: No such file or directory"

  • 1
    The source code is here: github.com/quick2wire/quick2wire-gpio-admin/blob/master/src/…. You could clone that project and edit the path, get that project onto your device and then rebuild it.
    – jfriend00
    Feb 21 '15 at 21:03
  • Hmmm I'm not sure how to exactly go about that and the link you posted is a 404 error. Do you know of any other way to interface with the GPIO pins through node.js Feb 22 '15 at 18:54

When the latest package raspberrypi-bootloader:armhf 1.20150130-1 was installed, the gpio symbolic links in /sys/class/gpio/ moved from /sys/devices/virtual/ to /sys/devices/soc/20200000.gpio.

Solution 1

chmod -R +x /sys/devices/soc/20200000.gpio

Solution 2

Update the pi-gpio.js so that

sysFsPath = "/sys/devices/virtual/gpio";

points to the new path:

sysFsPath = "/sys/class/gpio";

Solution 3

Add line device_tree= in /boot/config.txt. That will revert the links to be in the old path. Make sure you reboot after changing the config.txt.

Pick your flavor :)


I've fixed both pi-gpio (pull request #34) and gpio-admin (pull request #7) in a manner so that both the old and the new paths are supported. Hopefully, those pull requests are merged soon...


I had the same error as Matthew and after trying this solution I could see that Saran's fix had already been implemented into the "npm pi-pgio".

If you're still having this problem this solution worked for me. You need to update the path in gpio-admin.

First Download gpio-admin and open source code (I used nano, but any editor will do)

$git clone https://github.com/quick2wire/quick2wire-gpio-admin
$nano quick2wire-gpio-admin/src/gpio-admin.c

Check this file and make sure that the paths are updated. Update the function allow_access_by_user() the path needs to be updated to "/sys/class/gpio/gpio%u/%s"

Now navigate into the folder and install

$cd quick2wire-gpio-admin
$sudo make install

Note: you may need to add yourself as a user

$sudo add adduser $USERNAME gpio

Hope this helps save some headaches!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.