I am using rbenv on Debian. Debian came pre-installed with ruby 1.9.3. I installed rbenv and used it to install ruby 2.1.2. I then used rails new
to make a fresh rails application.
rbenv versions
gives
system
* 2.1.2 (set by /home/jordanmorris/code/TestRail/.ruby-version)
rbenv global
gives 2.1.2
rbenv local
(in the new application folder) gives 2.1.2
ruby -v
gives 2.1.2
which ruby
gives /home/jordanmorris/.rbenv/shims/ruby
However, when I use rails server
(node.js), view the 'Welcome aboard site' and click "About your application’s environment", it reports:
Ruby version
1.9.3-p484 (x86_64-linux)
Why is this not displaying the version set with rbenv as expected, and is this a cause for concern?
I only have one version of rails installed, afaik, and it reports correctly (4.1.4).
This answer helped me.
The problem was that I installed rails using sudo
.
rbenv operates on a per-user basis. So, rbenv install
installed ruby 2.1.2 for jordanmorris, whereas sudo gem install rails
installed rails using the only version of ruby/gem installed for root (1.9.3).
Afterwards, every time I ran rbenv
or ruby
, they used the expected rails version determined by rbenv, but every time I ran rails new
or rails server
, it would use the rails installed on top of ruby 1.9.3, that being the only instance of rails existing.
I followed these steps to fix it:
sudo
.rbenv rehash
.rails new
).The correct version now displays in the Welcome aboard -> About your application’s environment page.
Also note, the rails new
command will create an application which uses spring. Consider installing rbenv-binstubs to avoid stub clashes with rbenv.