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.
Related
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.
I created a Rails/React app with Webpacker on my Mac running Ruby 2.5.3 and it runs without issue. However when I clone it to my Ubuntu 18.04 machine, I get the below error :
/usr/lib/ruby/2.5.0/yaml.rb:5: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
My Ubuntu machine is also running Ruby 2.5.3, so I'm confused why it references 2.5.0 in the error.
I am able to launch the Rails server with rails s, but when I try to launch the full app with foreman start -f Procfile.dev, I get the error. I've tried reinstalling libyaml and all the Ruby versions on my machine with RVM with no impact on the error. I've also changed my local Ruby version to 2.5.0, and I get a different error message about how my machine is running Ruby 2.5.0 but the project is running 2.5.3.
Procfile.dev file:
rails: bundle exec rails s
webpack: ./bin/webpack-dev-serer
It says the project is running 2.5.0 based on a directive like ruby '~> 2.5' in the Gemfile. Try changing that to the actual version you're running, run bundle to setup Gemfile.lock again, and retry the command.
I had Ruby 2.5.1 installed from ‘sudo apt install Ruby’ and 2.5.3 installed from RVM. I wiped all installed Rubies and RVM, reinstalled 2.5.3 via RVM on the root directory and was good to go.
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 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
So I run this command successfully: sudo gem install rails
It outputs: Successfully installed rails-3.0.10
However, whenever I type in rails -v it shows: Rails 1.2.6
How can this be? Whenever I create a new project and do rails server, localhost:3000 doesn't work.
It's likely that your system has rails preinstalled, and the rubygems version is not overriding it.
You might have luck installing rvm and then installing rails within an rvm gemset.