2

I installed ruby using rbenv but after several attempts I don't manage to make the root user see the ruby bin.

I installed rbenv under /var/opt/rbenv

This is the content of /etc/profile.d/rbenv.sh:

export RBENV_ROOT=/var/opt/rbenv
export PATH=$RBENV_ROOT/bin:$PATH
eval "$(rbenv init -)"

As user pi, ruby -v returns ruby 2.2.2p95
But sudo ruby -v or ruby -v as root returns ruby not found.
How can I make root use my rbenv installation?
Should I fallback or RVM instead of rbenv?

Info: I need to run my ruby scripts as root in order to access the GPIOs.
Note: I need ruby >=2 so apt-get install ruby-full is not a solution.

Balzard
  • 121
  • 1

1 Answers1

1

If you are calling your script from rc.local then call . /etc/profile.d/rbenv.sh before your script in rc.local . You can use source instead of . . ~/.bashrc and ~/.profile can be used for per user login settings. printenv is a good tool to check what is set.

user1133275
  • 2,216
  • 16
  • 32