Using rbenv doesn't work with sudo?

后端 未结 4 1482
眼角桃花
眼角桃花 2020-12-10 07:56

Any commands that use sudo don\'t seem to work with RBenv.

I\'m trying to install ActiveRecord and it says I don\'t have write permission, so when I try

4条回答
  •  萌比男神i
    2020-12-10 08:13

    My answer in "Installing Ruby 2.0 and Rails 4.0.0beta on AWS EC2" might be useful to you.

    In short, the root user needs to have rbenv loaded in its environment for you to use the gems installed by rbenv. This can be done by adding the following

    # /etc/profile.d/rbenv.sh
    export RBENV_ROOT=/usr/local/rbenv
    export PATH="${RBENV_ROOT}/bin:$PATH"
    eval "$(rbenv init -)"
    

    This should be sufficient for sudo to work. If you are writing a shell script, you might need to use

    . /etc/profile.d/rbenv.sh 
    

    before using executables from other gems.

提交回复
热议问题