Ruby Developer Notes Useful things

5Sep/101

Bundler on heroku and without feature

Since bundler 1.0 release it recommends include Gemfile.lock into repository to force exactly the same gem environment for all users. Good idea, but here is one problem occurs - we can't use Gemfile hacks like this anymore:

[cc lang=ruby]
if RUBY_PLATFORM =~ /darwin/
gem "autotest-fsevent"
end
[/cc]

This case on other platform bundler will detect what gem "autotest-fsevent" is not present in Gemfile but presents in Gemfile.lock and fails.

2Aug/100

How to run Rails 3 rc on heroku

Heroku is awesome! You can easily run Rails 3 Beta on Heroku without any hacks. But if you want run Rails 3 RC where will be a problem: Rails 3.0.0.rc depends on Bundler 1.0.0.rc but Heroku now supports only Bundler 0.9.26. So you can't run app based on Rails 3.0.0.rc gem easily on Heroku now.

23Jun/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:
    [cc lang="bash" width="670"]
    # 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/
    [/cc]
13Jun/100

Ruby 1.9 + RVM + Ruby-Debug + Bundler

Как оказалось, установка отладчика ruby-debug для руби семейства 1.9 задачка не такая тривиальная, как кажется.

Во-первых, классический gem ruby-debug вообще не собирается под 1.9, но есть портированная версия, которая именуется ruby-debug19.

Во-вторых, ruby-debug19 тоже не заводится с полпинка. По умолчанию он ищет ruby19 где-то в недрах macports. А по-скольку этот способ установки руби нынче не в моде, то прийдется указать путь к сорцам руби явно. Например, для ruby 1.9.2 head установленного через rvm это выглядит так: