How to change line in gemfile? - ruby-on-rails

I want to change ruby 2.3.5 line in gemfile to ruby 2.4.2
but i did not know how?

inside your working folder there is file .ruby-version, change the content from 2.3.5 to 2.4.2 and then run steps below, if you working with rbenv
gem install bundler
rbenv rehash
ruby -v
# make sure it said 2.4.2
bundle install

Just open your Gemfile in a text editor and change the
ruby '2.3.5'
to
ruby '2.4.2'

You need to open your Gemfile and update ruby version ruby '2.4.2' Then you will need to go to terminal and install that version if not already installed. Use rvm use 2.4.3 (if you are using rvm) command to select 2.4.3 version.

Related

Your Ruby version is 2.6.0, but your Gemfile specified 2.5.0

Having trouble doing bundle.
My project is using 2.5.0 but every time i do ruby -v it gives me ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
I am using rbenv and my rbenv local is 2.5.0 and rbenv global is 2.5.0
Every time I do Bundle gives me an error Your Ruby version is 2.6.0, but your Gemfile specified 2.5.0
I have tried gem install bundler but it doesn't solves the problem.
source 'http://rubygems.org'
ruby '2.5.0'
gem 'rails', '5.0'
and my .ruby-version is also 2.5.0
Run
gem install bundler
or
gem update bundler
which may fix your problem.
I'm using macOS and managed to solve this problem by using rvm first to install the desired ruby version (2.5.7 in my case).
Step-by-step:
Install rvm from rvm.io - rvm version may be udpated with:
rvm get head
Add rvm to your shell configuration, e.g. ~/.bash_profile:
PATH=$PATH:$HOME/.rvm/bin
source /Users/<YOUR_USER_NAME>/.rvm/scripts/rvm
Using rvm, install new Ruby version:
rvm install ruby-2.5.7
Set the current/default version:
rvm use ruby-2.5.7 --default
Modify your Gemfile to use the new Ruby version. E.g.:
ruby '2.5.7'
Refresh the current Ruby version based on ./Gemfile by running:
rvm reload
After installing a new version, from your project dir do:
gem install bundler
bundle update
Delete Gemfile.lock and try with proper version of ruby and run bundle install.
if you are using zsh, open your .zshrc by running
nano ~/.zshrc
then add these lines to the file
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
then run
source ~/.zshrc
If you are using VS Code, in the Gemfile you have a specified version of Ruby that you can change. I just ran into this issue and once I changed the version to my current version of Ruby, it fixed it. Hope this helps anyone with same issue.

Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1

Whenever I run a Rails command, it states that my Ruby version is 2.3.1 but my Gemfile specified 2.5.1. However, "ruby -v" returns "ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]", my path has no references to ruby 2.3.1, and running "rvm list" shows a properly green highlighted 2.5.1. Bundler is installed, and when I try to run bundle install inside a created Rails folder, a get another "Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1" message. Please advise.
$PATH:
-bash: /home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/usr/share/rvm/rubies/ruby-2.5.1/bin:/usr/share/rvm/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
Further information in response to answers:
"which rails" returns "/home/alowverus/.rvm/gems/ruby-2.5.1/bin/rails", as expected
Create two files in the root one .ruby-version mention ruby-2.3.1 and .ruby-gemset mention #gemset-name and cd back to the same directory which will create the rvm wrapper for that application then run
rvm current
which outputs like something
ruby-2.3.1#gemset-name
then run
gem install bundler
bundle
may be helpful for you
I would try (in no particular order):
which rails, is it the correct one?
bundle exec rails c (or whatever your command is)
rvm reload
To start clean, rvm implode and try reinstalling rvm and your Ruby version.
Your Ruby version is 2.3.8, but your Gemfile specified 2.3.1
check ruby version with ruby -v [version like 2.3.8] make sure ruby version should be same on ruby versions as well as in your GemFile if you have not the same version then your put command on your bash_profile (terminal) rbenv global 2.3.8 & rbenv shell 2.3.8 (the version you can specified accordingly ) then delete your Gemfile.lock then install bundle and install bundler . these steps working form me.
rbenv global 2.3.8
rbenv shell 2.3.8
delete your Gemfile.lock
install bundle
install bundler

Your Ruby version is 2.3.3, but your Gemfile specified 2.1.10

I am trying to run bundle on 2.1.10 ruby version. using rbenv and my local and global is both ruby 2.1.10 but everytime i try to server or bundle it says.
Your Ruby version is 2.3.3, but your Gemfile specified 2.1.10
what would be the best possible way to fix or figure out the problem.
Run rvm use 2.1.10 if you used rvm to install ruby
if it is not installed it will give you the instructions to do it:
Required ruby-2.1.10 is not installed.
To install do: 'rvm install "ruby-2.1.10"'

Rails Seeing Incorrect Ruby Version

I've built a Rails 5 app and it's working great but I'd like to change the Ruby version I'm running it on. I'm using RVM 1.27.0 on Ubuntu 16.04. I copied the app folder to a different path and changed the versions on .ruby_version and my Gemfile:
Gemfile:
source 'https://rubygems.org'
ruby "2.2.2"
.ruby_version:
ruby-2.2.2
Once I updated these I moved out and back into the folder and ran a ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
I then ran a bundle install and everything installed without error.
However, when I ran rake -T I get this:
Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2.
My $PATH looks good:
/home/ken/.rvm/gems/ruby-2.2.2/bin:/home/ken/.rvm/gems/ruby-2.2.2#global/bin:/home/ken/.rvm/rubies/ruby-2.2.2/bin:/home/ken/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
What am I missing? Where is Rails pulling the Ruby version from? How can I fix this?
You're using a system bundler which is why you're seeing a different version of ruby. All you need to do is install bundler under your current ruby version:
gem install bundler
bundle install
Once you do a bundle install you'll get the gem's built for the correct ruby version.
The file name should be .ruby-version, not .ruby_version.
And you also should have file .ruby-gemset with content
gemset
check this link, Create .ruby-version and .ruby-gemset with rvm
You can also try spring stop and gem install bundler

Cant run rails commands. Your Ruby version is 2.2.1, but your Gemfile specified 2.1.4

I am not able to run surver rails s or cant make controllers etc. What should I do ?
Terminal showing following error:
Your Ruby version is 2.2.1, but your Gemfile specified 2.1.4
Run ruby -v then you will see that you've installed ruby 2.2.1, but the first line in your Gemfile specifies to use ruby 2.1.4. Change the first line in your Gemfile to specify ruby 2.2.1 or install ruby 2.1.4
If you want to use previous version ruby 2.1.4. Then first check if it is already installed or not by using rvm list command. If it is there then you need to run rvm use ruby-2.1.4 command and if it is not there use
rvm install ruby-2.1.4
rvm use ruby-2.1.4
It might be using your system ruby version
In your apache config use:
To find your path use passenger-config about ruby-command
PassengerRuby /home/user/.rbenv/versions/2.2.1/bin/ruby
Source: phusion passenger docs

Resources