Now I know why exactly, hack with checking out Rails in proper version into vendor/rails do the trick (see nhw.pl/wp/2006/05/09/how-to-survive-rails-upgrade).
Running script/server in first line reads config/boot.rb and there just after determining RAILS_ROOT in case is not defined we find:
if File.directory?("#{RAILS_ROOT}/vendor/rails")
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
else
require 'rubygems'
require 'initializer'
end
Everything is clear. But how version locking should be working as written on RoR wiki? Check wiki.rubyonrails.com/rails/pages/HowtoLockToSpecificRailsVersions.
It looks like config/environment.rb is called to late to set locking. BTW I did run server in debugger and it can not run, since some threading failure, but diving into Ruby code with debugger gave me enough information:
I have set breakpoint in config/environment.rb and when running server with debugger it goes in confg/boot to line require 'initializer'
, and in initalizer it fails with
./script/server:2:require File.dirname(__FILE__) + '/../config/boot' (rdb:1) c /usr/local/lib/ruby/1.8/drb/drb.rb:1647: `DRb::DRbServerNotFound' (DRb::DRbServerNotFound) from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session/drb_store.rb:8 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller.rb:56 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:181:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:167:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:166:in `activate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require' from ./script/../config/boot.rb:16 from ./script/server:2 /usr/local/lib/ruby/1.8/drb/drb.rb:1647: raise DRbServerNotFound unless server
Does not matter since stack gives info we already are in actionpack intialization:
(rdb:1) w --> #1 /usr/local/lib/ruby/1.8/drb/drb.rb:1647:in `current_server' #2 /usr/local/lib/ruby/1.8/drb/drb.rb:1681:in `config' #3 /usr/local/lib/ruby/1.8/drb/drb.rb:1041:in `initialize' #4 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session/drb_store.rb:8 #5 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session/drb_store.rb:7 #6 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session/drb_store.rb:6 #7 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session/drb_store.rb:5:in `require' #8 /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' #9 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:1:in `require' #10 /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' #11 /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller.rb:56:in `require' #12 /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' #13 /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:182:in `activate' #14 /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:167:in `activate' #15 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require' #16 ./script/../config/boot.rb:16
So breakpoint in config/environment.rb did not fire, ergo it is called later. So version lockin has to be done other way than Wiki says.
I see two solutions to lock rails version:
- checkout Rails code in needed revision into vendor/rails
- hack config/boot.rb, despite its header with DON’T EDIT THIS FILE :)))
Why Wiki has wrong info (at least now I think it is wrong), I don’t know…
SOLUTION
Wrong or not here You are with solution other than two points up: nhw.pl/wp/2006/05/13/upgrading-rails-and-locking-grande-finale
Leave a comment