I'm trying to set the environment for a RoR project on a new work pc.
When I try to install using bundle install, I get the following error:
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5
I'm using rbenv so I tried all the necessary rbenv tricks. Specifically I tried the following commands, each seperately:
rbenv install 2.5.5
rbenv rehash
rbenv local 2.5.5
rbenv global 2.5.5
I then retry bundle install but I'm still getting the same error.
I even tried
rbenv uninstall 2.6.8
but I'm getting:
rbenv: version `2.6.8' not installed
I of course tried restarting the computer totally after each of the steps but I'm still getting the same error. What am I doing wrong? How can I fix the correct version?
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'm trying to install the Gemfile contents using Bundle install but getting the error
rbenv: version `2.0.0' is not installed
The version of ruby installed in my system is:
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
and rbenv
2.1.2 (set by /home/jay/.rbenv/version)
2.1.3
The Gemfile requires ruby "2.0.0". Can any one tell how to install the required version without affecting the existing ones.
You can find a lot of information here: rbenv on github
To list all available installation candidates:
rbenv install -l
To install a ruby version you need (for example):
rbenv install 2.0.0-p643
So that you will only use this ruby version in this specific folder and not affect anything else you can do:
rbenv local 2.0.0-p643
This will generate a .ruby-version file in that directory which will force rbenv to use this ruby version here.
Just run:
rbenv install 2.0.0-p643
Which is the lastest 2.0.0 version.
If that version is not available on your system, run ruby-build --definitions to pick the lastest known 2.0.0 version on your system.
For me, I just ran
gem install bundler
and then run
bundle install
worked like a charm
You must change the ruby's version in .ruby-version file and in Gemfile
If you are getting a build failed error when trying to run rbenv install 2.0.0-p643 and after waiting for a few minutes; you might also see the last 10 lines of a log file as an output.
This can give you the hint of what would have happened for the build failure. It might miss some required library/dependency needed to be installed.
For ex. I got the following error for build failure-
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev` to fetch missing dependencies.
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
I'm trying to get a Middleman static site going but for the life of me cannot get Bundler to act right. This is my first time using Ruby on Rails.
Using rbenv I’ve cloned ruby 2.2.0 into a plugin folder but even after running rbenv global 2.2.0 and getting Middleman and Bundler to install, I can't get the "bundle install" or any other "bundle --" commands to work.
I was having issues with permissions and different versions of Ruby even after rbenv so I added "export RBENV_ROOT="$HOME/.rbenv" to my bash profile.
Once that was done the Ruby version issue that was keeping me from installing Bundler and Middleman was gone. But now that they're installed, I can't get these gems to follow any commands.
Try ruby -v to see what local ruby version is set in the app.
rbenv versions to see if you have that version installed. If you don't have the right version installed, run rbenv install ruby-x.x.x or whatever version is required, or if it is already installed do rbenv local x.x.x.
After installing a new ruby you need to run rbenv rehash to rehash your shims.
Then probably gem install bundler, then you can try bundle install.
After reading about Ruby gems and having no idea what rbenv or RVM was, I figured I should probably have one of the two.
I tried installing rbenv using Homebrew however it told me I had already installed rbenv. I always seem to have problems adding gems and usually end up using the sudo command to get it to work (which is a horrible idea I assume).
I discovered I had these problems when I was trying to add the braintree API gem and got an error whenever I tried to start the server.
Commands I tried:
gem install "braintree"
bundle install
sudo gem install "braintree"
The error received from running rails server was:
"/config/initializers/braintree.rb:2:in `<top (required)="">': uninitialized constant Braintree::Configuratio (NameError)"
To take it from the top, rbenv and RVM are Ruby version managers. This means that you can have multiple versions of Ruby installed on your computer at once and select which one you would like to use. I have used both and personally like rbenv's approach.
With that said I think you need to remove the quotes from around the name of the gem you are installing.
Also, in your Gemfile do you have the braintree gem listed? It should be as simple as gem 'braintree'.
If you have multiple versions of Ruby installed or even if you just have the system Ruby and a version installed with RVM or rbenv you may be starting your Rails server with the wrong Ruby version (ie it is missing the gem). You can see if it is using rbenv by typing which ruby and it should print something out with .rbenv/ whatever. If not you need to set rbenv as your current ruby. You can do that like rbenv global 2.1.1 where 2.1.1 is the version of ruby you installed with rbenv. If you haven't installed a version with rbenv you can use ruby-build and do rbenv install 2.1.1 or whatever version you want. Then when you launch your Rails server prefixing the command with bundle exec.
You can set a local ruby-version for your directory by executing rbenv local 2.1.1 once again where 2.1.1 is the version you want.
Reading the rbenv docs will go a long way.
To check if you are using rbenv, simply use this
rbenv
*check if 'rbenv' commands were listed
Same with rvm use
rvm
Run the command rbenv in terminal. If you have rbenv installed, it will list some help commands. If rbenv is not installed, it will output something like "No command 'rbenv' found"
Run the command rvm in terminal. If you have RVM installed, it will list some help commands. If rvm is not installed, it will output something like "No command 'rvm' found"