Search code examples
rubyrbenv

RBENV resolve duplicate directories for ruby-build


I recently updated my ruby version for the first time since installing rbenv. On my development machine I discovered that I needed to reinstall bundler and all my gems again for each application using bundle install.

Now, when I login to my production server I notice that I have a ruby-build directory in my home folder at ~/ruby-build and in .rbenv/plugins. How can I find out which one my server is using and so which one to run git pull and install the new version of ruby? Can I just delete the directory at ~/ruby-build and deal with the other? Doing some exploring I find I also have a ruby-build in usr/local/bin on my server but this is not a directory.

I am completely confused by all of this. Rbenv lives in my home directory, rather than in any system directory on the server. Does this matter? How does it still work on a server even if I am not logged in?

Running rbenv versions from my home directory on the server reports "The program 'rbenv' is currently not installed" but lists the versions installed on my development laptop.

My .bashrc on the sever contains this entry at the top

if [ -d "${RBENV_ROOT}" ]; then
  export PATH="${RBENV_ROOT}/bin:${PATH}"
  eval "$(rbenv init -)"
fi

My .bashrc on my development laptop contains this entry at the bottom.

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Solution

  • Since you include that in your .bashrc, I imagine that if you were to echo $RBENV_ROOT in the terminal you'll find out which rbenv directory is the one being used.

    Although, you say that the rbenv command doesn't work so perhaps $RBENV_ROOT is not defined. In that case, you can simply do something like RBENV_ROOT=$HOME/.rbenv/ before that conditional -- or whatever you like -- to set the rbenv directory it should use.

    When you do that, to define $RBENV_ROOT, re-login to make the changes take effect, or re-source the .bashrc file with source ~/.bashrc.