I am running Ruby -v 2.2.0
Everytime I run the rails new or rails -v I get an error that reads:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.2.0
I was running Ruby 2.1.5 but just switched to 2.2.0 because of the error message. Now that I switched I am still getting the same error message. Does anyone know what the problem could be?
Every installed ruby version have separate set of gems.
This rbenv message says that rails gem installed only in 2.2.0 version but currently rbenv set to use some another version.
You can list of available rbenv commands by rbenv command in terminal. There are some useful of them which may help to solve this question:
rbenv versions will display all installed ruby versions (and show asterisk with currently selected version).
rbenv global 2.2.0 will set global Ruby version.
rbenv local 2.2.0 will set Ruby version for current folder only.
rbenv shell 2.2.0 will set Ruby for current shell session only.
It could be that proper version of Ruby not installed. Install it and Bundle:
rvm install 2.2.0
bundle install
Related
I am using ruby 2.7.6 for my project. On my laptop (KDE Neon) it was installed via rbenv and was working correctly.
After KDE was updated today I started getting
Your Ruby version is 3.0.2, but your Gemfile specified 2.7.6
To fix that I tried reinstalling both rbenv and ruby that comes with Ubuntu. Also tried rbenv rehash with no results. So far rbenv installs ruby correctly and correct vesion is displayed when I do ruby -v or bundle install in project folder but trying to run rails s gives me an error
Your Ruby version is 3.0.2, but your Gemfile specified 2.7.6
rbenv is installed into /home/some_user/.rbenv/
$PATH shows
bash: /home/some_user/.rbenv/shims:/home/some_user/.rbenv/shims:/home/some_user/.rbenv/bin:/home/some_user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin which I am not sure is correct.
You're not running the correct rails executable. Try prefixing your rails command with bundle exec, for example if you want to run the dev server, type bundle exec rails s instead of rails s.
I have installed RVM successfully on my Mac and using it I have installed Ruby 2.6.3. I have set my current and default version of Ruby to be 2.6.3. Everything seems to be fine because when I enter ruby -v into the terminal it tells me I'm using ruby 2.6.3.
My problem comes when I try to install Rails 6, I'm entering:
gem install rails --version=6.0.0 -no-ri -no-rdoc
It seems to install correctly however when I try to confirm with:
rails -v
I get:
Rails 6 requires Ruby 2.5.0 or newer.
You're running
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64- darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
Why am I getting this message when my ruby -v command is telling me that I am using ruby 2.6.3
Any help would be very welcome.
You're running ruby 2.3.7p456. You need to set your local ruby version to 2.6.3.
Try which ruby to see which ruby version is loaded.
rvm install 2.6.3
rvm use 2.6.3
You can then see which ruby is running with which ruby.
See the basics on the rvm docs
As an aside, I also recommend recommend rbenv over rvm; however, you can only have one installed. If you have both installed, you're going to have a bad time.
To make sure you do not have both installed try which rbenv, and that should return rbenv not found
Please edit your original question with the output of the following commands:
which -a ruby
echo $PATH (That will help debug if your $PATH is set up incorrectly.)
which rbenv
ls (in your project directory)
i also had the similar problem which i resolved by uninstalling rvm completely and then installing rbenv.
Trying to install rails version 4.2.5 on Ubuntu in Windows Subsystem for Linux on Windows 10 when I have ruby 2.2.1 installed and active I get the following error:
~$ gem install rails -v 4.2.5
ERROR: Error installing rails:
nokogiri requires Ruby version >= 2.3.0.
I need these versions to collaborate on a project which uses these versions.
I started by installing WSL (1 not 2) on windows 10, then downloaded and installed Ubuntu Linux. Then I installed rbenv, updated dependencies, installed ruby 2.5.1 which was fairly easy.
I had problems installing ruby 2.2.1 but got there after doing
$ sudo apt-get install -y libssl1.0-dev
to install an earlier version of libssl which ruby 2.2.1 needs.
I installed node.js and an earlier version of bundler using
$ gem install bundler -v 1.17.3
as trying
$ gem install bundler
failed with a similar error.
(I also installed ruby 2.5.1 and rails 4.2.5 on top of it with few problems)
Trying various diagnostics showed rails was not installed for ruby 2.2.1
~$ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.5.1
(but not in ruby 2.2.1, which is where I need it)
Looking at my files in windows File Explorer (only looking) I can see that while my ruby 2.5.1 gems include rails my ruby 2.2.1 files are incomplete and do not include rails.
I think the PATH is correct.
$ echo $PATH returns
/home/johnloughran/.rbenv/plugins/ruby- build/bin:/home/johnloughran/.rbenv/shims:/home/johnloughran/.rbenv/bin:/usr/
local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local
/games:/mnt/c/Program
Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2019.522.0_
x64__79rhkp1fndgsc: ........ :/snap/bin
I modified my .bashrc file to add various entries to the PATH which have been included above.
I repeated the whole process twice starting from scratch (uninstalling Ubuntu) with the same block at the end.
What is my best option here to try and continue?
Thanks Josien for your comments. In the first case my collaborators have these versions of Ruby and Rails working together, but its a few years now since they installed them. One, David, helped me by trying a fresh install of rails 4.2.5 on ruby 2.2.1 which ran into the same problem above with nokogiri.
He solved it by installing a lower version of nokogiri in a new test directory, which I repeated as:
test$ gem install nokogiri -v 1.9.1
This worked. Then I installed rails as
test$ gem install rails --version 4.2.5
At last .... it worked!!!! :-)
To prove it I was able to get rails to return its version correctly.
test$ rails -v
Rails 4.2.5
Then I was able to create an app as
<working-directory>$ rails new learn-ruby
which works, almost, having hit another dependency problem, but hey ... that's programming!
Re your second comment I do not know enough about this stuff to know how relevant it is that this version of ruby is deprecated and the rails version is getting there too.
I'm trying to setup a rails app on a new machine and I'm having some trouble. I'm using a .ruby-version file to specify the ruby version we're using for the project which contains the following:
2.0.0-p643
Here's what happens when I try to look at what ruby versions I'm using
➜ app git:(master) ✗ rbenv versions
system
* 2.0.0-p643 (set by /Users/stephen/workspace/prm/.ruby-version)
➜ app git:(master) ✗ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-darwin14.5.0]
So far so good. And yet when I try to install my dependencies with bundler, I get this:
➜ app git:(master) ✗ bundle
Your Ruby version is 2.2.3, but your Gemfile specified 2.0.0
Why does rbenv report to me that I'm using the version I've intended by my ruby-version file yet when I try to run bundle it complains that I'm using the wrong version? I could see if it said that the patch level is causing problems because my gemfile just specifies 2.0.0 but why is it telling me that I'm using 2.2.3 when rbenv is telling me otherwise.
I tried uninstalling bundler, thinking that perhaps the bundler was the system bundler for some reason and that's what was causing the problem. Same problem.
For reference this is using the latest version of rbenv that was installed using homebrew on OSX Yosemite.
I'm running Ubuntu 12.04 LTS, and installed Ruby via RVM.
The problem is, when I type ruby -v into the terminal, it says that my Ruby version is 1.8.7, and using the shotgun gem for Sinatra also says that I'm running Ruby 1.8.7.
But when I type rvm list it shows that the only version of Ruby that I have installed is 2.0.0 and it is my current and default version.
I installed Ruby 2.0.0 via RVM and it is the only version I had installed on my machine.
Now when I tried to install Rails 4 but got an error saying that I need Ruby 1.9 or higher.
How do I know what version am I really on, and how do I set 2.0.0 as my only version?
On your terminal, try running:
which -a ruby
This will output all the installed Ruby versions (via RVM, or otherwise) on your system in your PATH. If 1.8.7 is your system Ruby version, you can uninstall the system Ruby using:
sudo apt-get purge ruby
Once you have made sure you have Ruby installed via RVM alone, in your login shell you can type:
rvm --default use 2.0.0
You don't need to do this if you have only one Ruby version installed.
If you still face issues with any system Ruby files, try running:
dpkg-query -l '*ruby*'
This will output a bunch of Ruby-related files and packages which are, or were, installed on your system at the system level. Check the status of each to find if any of them is native and is causing issues.
Run this command:
rvm get stable --auto-dotfiles
and make sure to read all the output. RVM will tell you if something is wrong, which in your case might be because GEM_HOME is set to something different then PATH.
The ruby version 1.8.7 seems to be your system ruby.
Normally you can choose the ruby version you'd like, if you are using rvm with following. Simple change into your directory in a new terminal and type in:
rvm use 2.0.0
You can find more details about rvm here: http://rvm.io
Open the website and scroll down, you will see a few helpful links. "Setting up default rubies" for example could help you.
Update:
To set the ruby as default:
rvm use 2.0.0 --default
If you have access to a console in the context you are investigating, you can determine which version you are running by printing the value of the global constant RUBY_VERSION.