Rails version coexistence

Hi,

What is the correct way to get multiple rails installs to cooperate with
each other?

I’ve got nine projects that I built on my (windows) workstation and
deployed to a linux server. The linux server is running ruby 1.8.4 and
rails 1.1.6. Another project came along and it was built on a different
workstation, by a different developer, and I helped out after the fact.
It’s on rails 1.2.3, which is frozen in the vendor subdirectory for that
particular project.

In order to get things working on my local workstation, I had to update
all of the gems, and I believe ruby. gem list on my local machine shows
rails at 1.2.3 and 1.1.6. ruby -v shows 1.8.6.

However, since that update, I can’t start the local server on any of the
older projects, which is hurting my ability to get anything done in
those projects.

script/server on my workstation returns:
ruby script/server
./script/…/config/boot.rb:28:Warning: require_gem is obsolete. Use gem
instead.

The server starts, but will not process requests without throwing an
“application error”

The development log shows the following:

$ tail -f development.log
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch ' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick. rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_re
quire’
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/de pendenci es.rb:147:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_re quire' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/de
pendenci
es.rb:147:in require' script/server:3 wrong number of arguments (1 for 0) c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/ven dor/mysq l.rb:551:ininitialize’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/ven
dor/mysq
l.rb:551:in new' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/ven dor/mysq l.rb:551:inscramble41’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/ven
dor/mysq
l.rb:141:in real_connect' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con nection_ adapters/mysql_adapter.rb:330:inconnect’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con
nection_
adapters/mysql_adapter.rb:87:in initialize' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con nection_ adapters/mysql_adapter.rb:36:innew’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con
nection_
adapters/mysql_adapter.rb:36:in mysql_connection' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con nection_ adapters/abstract/connection_specification.rb:251:insend’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con
nection_
adapters/abstract/connection_specification.rb:251:in
connection_without_query_c ache=' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/que ry_cache .rb:54:inconnection=’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con
nection_
adapters/abstract/connection_specification.rb:220:in
retrieve_connection' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/con nection_ adapters/abstract/connection_specification.rb:78:inconnection’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/bas
e.rb:696
:in columns' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/bas e.rb:704 :incolumns_hash’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/s
ession/a
ctive_record_store.rb:103:in setup_sessid_compatibility!' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/s ession/a ctive_record_store.rb:77:infind_by_session_id’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/s
ession/a
ctive_record_store.rb:281:in initialize' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/bas e.rb:794 :insilence’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/s
ession/a
ctive_record_store.rb:281:in initialize' c:/ruby/lib/ruby/1.8/cgi/session.rb:273:innew’
c:/ruby/lib/ruby/1.8/cgi/session.rb:273:in initialize' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/c gi_proce ss.rb:112:innew’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/c
gi_proce
ss.rb:112:in session' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/c gi_proce ss.rb:142:instale_session_check!’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/c
gi_proce
ss.rb:108:in session' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/b ase.rb:9 18:inassign_shortcuts_without_flash’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/f
lash.rb:
141:in assign_shortcuts' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/b ase.rb:4 02:inprocess_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/f
ilters.r
b:377:in process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/s ession_m anagement.rb:117:inprocess’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:inhandle_
dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
`service’

c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in each' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:instart’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch ' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick. rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_re
quire’
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/de pendenci es.rb:147:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_re quire' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/de
pendenci
es.rb:147:in `require’
script/server:3

So, for the short term, how can I get get webrick to run both the old
projects and new projects, on my local workstation, as needed, keeping
in mind that the production server runs ruby 1.8.4 and rails 1.1.6?
Second, is there a ‘correct’ way to upgrade a rails app from an older
release? For example, I see that the boot.rb files from the older and
newer projects have some differences.

Thank you.

Regards,

Rich

On Aug 3, 2007, at 13:51 , Duzenbury, Rich wrote:

What is the correct way to get multiple rails installs to cooperate
with
each other?

AIUI, using vendor/rails is the standard way.

particular project.
I’d consider going ahead and freezing Rails in each app, just to keep
things stable for each.

However, since that update, I can’t start the local server on any
of the
older projects, which is hurting my ability to get anything done in
those projects.

I can imagine! Are the production installations working okay? If so,
you can check which versions of Ruby and gems are used, and use them
to reconfigure the development machines.

script/server on my workstation returns:
ruby script/server
./script/…/config/boot.rb:28:Warning: require_gem is obsolete.
Use gem
instead.

As it says, this is just an warning, so I don’t think you need to
worry about this, at least for now. (Though you should consider
upgrading your Rails in these so this warning goes away.)

dor/mysq
active_record/con
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/
active_record/con
nection_

It looks like you might be having problems connecting to your
database server. Can you connect to your database outside of Rails
using the configuration in database.yml? If not, I think that’s your
error.

So, for the short term, how can I get get webrick to run both the old
projects and new projects, on my local workstation, as needed, keeping
in mind that the production server runs ruby 1.8.4 and rails 1.1.6?
Second, is there a ‘correct’ way to upgrade a rails app from an older
release? For example, I see that the boot.rb files from the older and
newer projects have some differences.

I don’t know if there are any specific issues with using Ruby 1.8.4
with Rails 1.1.6. The current recommendations are 1.8.5 for Rails 1.2.

Good luck!

Michael G.
grzm seespotcode net

On Aug 3, 2007, at 13:51 , Duzenbury, Rich wrote:

different workstation, by a different developer, and I helped out
anything done
instead.
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/
l.rb:141:in `real_connect’
nection_
database server. Can you connect to your database outside of
release? For example, I see that the boot.rb files from
grzm seespotcode net

Hi,

Thanks for the info, it is helpful. In answer to your questions, all
the sites work fine on the production server, which is rails 1.1.6, and
ruby 1.8.4. I had to upgrade my workstation, which is now rails 1.2.3
and ruby 1.8.6. It’s my workstation that can’t seem to play in both the
old and new rails sites. The old sites throw an error in the mysql
module.

After digging around in the mysql.rb of active record, I discovered
there is a co-existence problem between rails 1.1.6 and ruby 1.8.6.
Specifically, the Digest::SHA1 interface was changed. Not sure why.

Here is my hack:

def scramble41(password, message)
return 0x00.chr if password.nil? or password.empty?
buf = [0x14]

# Work with older or newer ruby
if RUBY_VERSION.gsub(/\./, '').to_i < 186
  s1 = Digest::SHA1.new(password).digest
  s2 = Digest::SHA1.new(s1).digest
  x  = Digest::SHA1.new(message + s2).digest
else
  s1 = Digest::SHA1.digest(password)
  s2 = Digest::SHA1.digest(s1)
  x  = Digest::SHA1.digest(message + s2)
end

(0..s1.length - 1).each {|i| buf.push(s1[i] ^ x[i])}
buf.pack("C*")

end

At least I can work with both the old and new projects on my workstation
now.

Thank you.

Regards,
Rich