Changing rvm_ruby_version doesn't change the ruby version - rvm

In my deploy.rb I have set :rvm_ruby_version, '1.9.3'
In ../shared/bundle/ruby/ I see 1.9.1
Why is this not 1.9.3?
Update
I added ruby 1.9.3 to my gemfile.
I am seeing commands like this:
/home/rails/.rvm/rubies/ruby-1.9.3-p448/bin/ruby /home/rails/rails-capistrano/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets
Why go into bundle/ruby/1.9.1?

1.9.1 is a ruby compatibility version, this means that all 1.9.x rubies are supposed to be binary compatible

Related

Rails 4.0.8 Bundle Install keeps poiting to the wrong Ruby version

I'm working through the Railstutorial with Rails 4.0.8. and Ruby 2.1.2. Recently Bundle Install, Rails Console and Rails Server seem to ALWAYS choose the alternate version of Ruby from whichever is specify in my Gemfile. When I enter ruby -v it also always suggests the OTHER version.
Is this a bash_profile problem and how can I set it to permanently leave the internal OS X Ruby (v2.0.0) alone and just use v 2.1.2 where all my gems are installed?
I'm using rvm and Homebrew... I suspect both may be adding to the confusion...
Any helpful tips?
First...
micanansmbp:sample_app micanan$ rails console
Your Ruby version is 2.1.2, but your Gemfile specified 2.0.0
Then...
micanansmbp:sample_app micanan$ bundle install
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
Finally...
micanansmbp:sample_app micanan$ bundle install
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
micanansmbp:sample_app micanan$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
micanansmbp:sample_app micanan$

Gem::LoadError: Could not find rubygems-bundler (>= 0) amongst []

I'm running rvm with ruby 1.9.3. I've ran bundle install and it worked fine. But when I run bundle install --deployment I get this:
volunteer-app ➜ bundle install --deployment
Fetching gem metadata from http://rubygems.org/.......
Installing rake (0.9.2.2)
Gem::LoadError: Could not find rubygems-bundler (>= 0) amongst []
An error occured while installing rake (0.9.2.2), and Bundler cannot continue.
Make sure that `gem install rake -v '0.9.2.2'` succeeds before bundling.
After this is ran I look in the vendor/bundle/ruby directory and it shows 1.9.1. So it looks like bundle install --deployment isn't recognizing my gems in from rvm's default ruby version 1.9.3.
Any thoughts on what I could be missing.
Edit
Here's my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer
- RUBY EXECUTABLE: /home/sosl/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer
- /home/sosl/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It's a bug in both rubygems-bundler and bundler, I have already fixed it for rubygems-bundler and a fix for bundler is waiting for merge.
Fastest way to fix is to update rubygems-bundler:
gem update rubygems-bundler
For reference here is pull request for bundler:
https://github.com/carlhuda/bundler/pull/1925
I really feel for you as I just went though something simular last night. While I am certainly not an expert (I am just a student of RoR as you are) can I make some suggestions?
After you use RVM to change into your RUBY version, run a "local" gem list to see what gems are installed locally. Do you have the gem installed in your local gems?
Sometimes gem files get "Jumbled" and stop working altogether. Have you tried to uninstall and then reinstall the gems? The command is simple. In your console type "gem uninstall (the name and version number of the gem you wish to uninstall). It may reply that the gem you wish to uninstall has dependencies on other gems you have installed. Don't worry once you reinstall those gems the dependencies will be satisfied.
I don't know if Bundler is installed automatically or not. Is it listed in your "Local" gems or in your gemfile.lock?
Best of luck in correcting this.

Can RVM hide a gem from the global gemset?

The project I'm about to work on asks for version 1.0.10 of bundler and version 0.8.7 of rake. My global gemset has slightly newer versions of these gems. I.e., the install instructions for the new project look like this:
rvm gemset use rails3
gem uninstall -x bundler
gem install bundler -v 1.0.10
gem uninstall -x rake
gem install rake -v 0.8.7 # Rake needs to be at 0.8.7
What happens is that when I'm in this new rails3 gemset I can't uninstall the existing gems (and personally I don't want to) because they exist in the global gemset.
So, question: can I somehow hide those two gems that exist in the global gemset?
I can list the gems:
$ gem list
*** LOCAL GEMS ***
addressable (2.2.6)
archive-tar-minitar (0.5.2)
awesome_print (1.0.1)
bundler (1.0.21, 1.0.10)
...
rake (0.9.2.2, 0.8.7)
...
Maybe an ancillary question would be: since I have installed the older versions into the the rails3 gemset, will rvm prefer those because the fact they were specifically installed somehow overrides the version in global, or will rvm take the gems with the highest version number?
any command except bundle should be prefixed with bundle exec and this will assure proper version of gem is used (using Gemfile)
you can avoid writing always bundle exec by using my gem rubygems-bundler
for running bundle command - rubygems will select latest available version if you do not specify one ex. bundle _1.0.10_ exec rake db:create

debug rails 3.1.1 application

I'm try to add a debugger to my rails 3.1.1 application which uses ruby 1.9.2. I have added the following to my gemfile:
gem 'ruby-debug19', :require => 'ruby-debug'
and I get the following error:
/.rvm/gems/ruby-1.9.2-p290#rails31/gems/ruby-debug19-0.11.6/cli/ruby-debug/interface.rb:55:in `block (2 levels) in initialize': uninitialized constant Debugger::LocalInterface::Readline (NameError)
by the way i have the following:
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
$ rails -v
Rails 3.1.1
$ rvm -v
rvm 1.8.6 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]
What made is work for me is:
sudo gem install ruby-debug19
gem install linecache19
gem install ruby-debug-base19
bundle update
rails server -u
Did you install all the prerequisites listed in rvm notes before you installed Ruby? I'm not positive, but I think readline is a dependency for MRI on Linux.
You may also follow these instructions from the RVM site:
If you have an error when compiling pertaining to readline, you may
need to attempt installing with the procedure defined below.
NOTE: Before you follow the procedure below please be sure to verify
that you have installed any dependencies for the Ruby you are
installing listed by the 'rvm notes' command. If you have not yet done
that do so then run 'rvm remove X ; rvm install X' where X is the Ruby
that you are concerned with.
$ rvm pkg install readline
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-readline-dir=$rvm_path/usr

annotate cannot find rake executable

I'm using ctran/annotate_models to annotate my models and route files. I'm now getting an error:
$ annotate -r
$ROOT/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:151:in `block in cripple_rubygems': can't find executable rake (Gem::Exception)
from $ROOT/usr/lib/ruby/gems/1.9.1/bin/rake:19:in `<main>'
Route file annotated.
...with the result that annotate adds the comment block to config/routes.db, but the comment is empty. The message suggests that annotate can't find rake, but rake is certainly there:
$ which rake
$ROOT/usr/bin/rake
and here's what rake says about the current configuration:
$ rake about
About your application's environment
Ruby version 1.9.2 (x86_64-darwin10.6.0)
RubyGems version 1.3.7
Rack version 1.2
Rails version 3.0.5
Active Record version 3.0.5
Action Pack version 3.0.5
Active Resource version 3.0.5
Action Mailer version 3.0.5
Active Support version 3.0.5
Application root .../myapp
Environment development
The only things that's slightly odd in my Gemfile is that I am specifying a previous version of rake:
# file: Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'rake', '0.8.7' # workaround "uninitialized constant Rake::DSL" bug
...
gem 'annotate', '2.4.0'
Any ideas of what's wrong?
Try using bundle exec rake instead.