Why is bundler picking up the wrong ruby version? - ruby

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ bundle exec rake assets:precompile
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.2
$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.2
$ ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ ~/.rvm/bin/rvm default do ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ which ruby
/home/sardsapp/.rvm/rubies/ruby-2.7.2/bin/ruby
I don't even know where to start with this. I even rebooted the machine, those commands are verbatim. I can't figure out what could possibly going wrong.
My Gemfile does specify 2.7.2, and that is my default version of ruby through rvm. I uninstalled all the other rvm versions of ruby. I don't have the ubuntu ruby package installed.

You can create a new gemset and switch the ruby version to 2.7.2

Related

Managing rubies with rvm but rbenv replying with ruby version not installed

I used to use rbenv to manage ruby versions. I uninstalled it because I had to switch to rvm to install an old version of ruby. Now in my project, if I do ruby -v I get ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] but when I try to create my database with bundle exec rails db:create I get rbenv: version '2.3.1' is not installed. Can someone help me with that ?

Sassc-2.0.0 requires ruby version >= 2.3.3, which is incompatible with the current version, ruby 2.3.0p0

When I type bundle install, I get this message error:
sassc-2.0.0 requires ruby version >= 2.3.3, which is incompatible with the current version, ruby 2.3.0p0.
But I clean up my computer and there is no more version 2.3.0p0.
Here is the result of bundle env :
Environment
Bundler 1.17.2
Platforms ruby, x86_64-linux
Ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
Full Path /usr/share/rvm/rubies/ruby-2.6.1/bin/ruby
Config Dir /usr/share/rvm/rubies/ruby-2.6.1/etc
RubyGems 3.0.1
Gem Home /usr/share/rvm/gems/ruby-2.6.1
Gem Path /usr/share/rvm/gems/ruby-2.6.1:/usr/share/rvm/gems/ruby-2.6.1#global
User Path /root/.gem/ruby/2.6.0
Bin Dir /usr/share/rvm/gems/ruby-2.6.1/bin
Tools
Git 2.7.4
RVM 1.29.7 (manual)
rbenv rbenv 0.4.0
chruby not installed
rubygems-bundler (1.4.5)
Bundler Build Metadata
Built At 2018-12-19
Git SHA 3fc4de72b
Released Version false
Thanks for your help.
It's exactly the same issue :
Trouble removing ruby 2.3.0p0 from Ubuntu
There is still a file ruby2.3 in usr/bin.

Ruby RVM gives me version 2.0 but Bundler says I'm incorrectly running version 2.3

I am just starting to work on an old Ruby Rails project. The Gemfile specifies:
ruby '2.0.0'
I am running a new version of Ubuntu, which I think came with Ruby 2.3 as the default. So I install RVM and then I:
rvm --default use 2.0.0
ruby -v
which gives me:
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
then I run:
bundle install
and I get this error:
Your Ruby version is 2.3.1, but your Gemfile specified 2.0.0
How do I get RVM to enforce the correct version of Ruby?

OSX not using latest Ruby version

When I try to run a ruby command in terminal I get an error:
Ruby >= 2.1.9 required to run app (You have 2.0.0)
When I try
brew upgrade ruby
I get
Error: ruby 2.3.1 already installed
Previously I tried installing ruby with rvm
curl -sSL https://get.rvm.io | bash -s stable --ruby
Maybe I have two different versions of ruby running?
How can I get my system to use the latest version of ruby?
EDIT: Definitely two versions installed
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
My $PATH seems correct?
-bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
EDIT2 specifying the full path to the correct version of ruby:
/usr/local/bin/ruby app.rb
/usr/local/bin/ruby: No such file or directory -- app (LoadError)
In the simplest cases, you can just specify the fully-qualified PATH to your Homebrew-installed Ruby. For example:
/usr/local/bin/ruby /path/to/foo.rb
However, if you need to require gems or libraries, you need to step up your game with a Ruby version manager such as chruby, rvm, or rbenv. You should never replace the system ruby, and managing all the environments variables, gems, and so forth that Ruby needs without a version manager is outside the scope of a reasonable Stack Overflow question.
You have installed the homebrew version 2.3.1 of Ruby, but you are not using it because you haven't set your PATH correctly.
Try using the one homebrew installed for you by adding /usr/local/bin to the start of you PATH, or by running:
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
I guess if you use the Apple-supplied Ruby in /usr/bin you will get:
/usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
You should uninstall ruby from brew and just use rvm.
If you have multiple version installed than you can use rvm to make ruby 2.3.1 your default: rvm --default use 2.1.1

Cannot find gem after bundle install

I'm trying to setup my environment to do development on Travis CI's dpl project.
I installed rbenv to manage my Ruby versions and I use Ruby 2.2.3.
Then I do bundle install and the gems are installed.
Then when I try to do bundle exec rake I get this error:
Could not find CFPropertyList-2.2.8 in any of the sources
Run `bundle install` to install missing gems.
This gem is installed. Can you tell me why it is not found by Bundler?
Here is a gist of the output of my commands: https://gist.github.com/cotsog/7bb87c84a636bcd3de65
Thanks for your help!
Update:
Additional info about my environment:
$ which ruby
/Users/me/.rbenv/shims/ruby
$ which bundler
/usr/bin/bundler
$ ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
$ bundler --version
Bundler version 1.10.6

Resources