Заметки Ruby программиста Всякие полезные наработки

23Июн/101

Cross version Ruby debug with ruby-debug-wrapper

When you debuging Rails 3 application (which uses Bundler) and trying different ruby versions with RVM you have following problem: you should switch your Gemfile between ruby-debug and ruby-debug19 gems to work with 1.8 and 1.9 Rubies. ruby-debug-wrapper gem solves the problem.

Follow this steps:

  1. Install ruby-debug gem for each ruby version you will use. For example:
     # rvm use system
     # gem install ruby-debug
     # rvm use ree@rails3
     # gem install ruby-debug -- --with-ruby-include=$rvm_path/src/ree-1.8.7-2010.02/
     # rvm use ruby-1.9.2-head@rails3
     # gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-head/
  2. Add to Gemfile following line
     gem 'ruby-debug-wrapper', :group => :development
  3. Run bundler
     # bundle install
  4. Now you can run server with debugger and switch ruby version without changing Gemfile each time:
     # rvm use system
     # script/rails s -u
     # rvm use ree@rails3
     # script/rails s -u
     # rvm use ruby-1.9.2-head@rails3
     # script/rails s -u

Possibly my solution is still raw. So waiting for your comments and bug reports. Hope this can save few minutes to someone.

P.S.
Few days after i have found more simpler solution. You can just include following lines to your Gemfile:

if RUBY_VERSION < '1.9'
  gem 'ruby-debug'
else
  gem 'ruby-debug19'
end

So i was on the wrong way. 🙂

Комментарии (1) Пинги (0)
  1. I think Bundler ‘platforms’ are intended for this — you can do something like:

    gem ‘ruby-debug’, :platform => :ruby_18
    gem ‘ruby-debug19’, :platform => :ruby_19

    More info here: http://gembundler.com/man/gemfile.5.html


Leave a comment

Нет обратных ссылок на эту запись.