Thin server claims I don't have correct rails gem installed

Hi everyone, I need some insight into a problem I just started having.

I’m running ruby 1.8.6 on an ubuntu box with the following gems
installed:

$ sudo gem list --local

*** LOCAL GEMS ***

actionmailer (2.3.5, 2.3.4, 2.3.2, 2.2.2)
actionpack (2.3.5, 2.3.4, 2.3.2, 2.2.2)
activerecord (2.3.5, 2.3.4, 2.3.2, 2.2.2)
activeresource (2.3.5, 2.3.4, 2.3.2, 2.2.2)
activesupport (2.3.5, 2.3.4, 2.3.2, 2.2.2)
Ascii85 (1.0.0, 0.9.0)
capistrano (2.5.11, 2.5.10, 2.5.5)
columnize (0.3.1, 0.3.0)
daemons (1.0.10)
eventmachine (0.12.10, 0.12.6)
ezcrypto (0.7.2)
gem_plugin (0.2.3)
highline (1.5.1)
linecache (0.43)
mocha (0.9.8)
net-scp (1.0.2)
net-sftp (2.0.4, 2.0.2)
net-ssh (2.0.17, 2.0.16, 2.0.11)
net-ssh-gateway (1.0.1)
pdf-reader (0.8.2, 0.8.1)
prawn (0.7.1, 0.6.3)
prawn-core (0.7.1, 0.6.3)
prawn-format (0.2.3)
prawn-layout (0.7.1, 0.3.2)
prawn-security (0.7.1, 0.1.1)
rack (1.1.0, 1.0.1, 1.0.0, 0.9.1)
rails (2.3.5, 2.3.4, 2.3.2, 2.2.2)
rake (0.8.7, 0.8.4, 0.8.3)
rghost (0.8.7.2, 0.8.6.5, 0.8.6.3)
rghost_barcode (0.8)
rmagick (2.12.2, 2.9.1)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
rubygems-update (1.3.5, 1.3.2)
sqlite3-ruby (1.2.5, 1.2.4)
test-spec (0.10.0)
thin (1.2.5, 1.0.0)

I’ve got a rails 2.3.5 app that I’ve developed and that runs fine
using the traditional WEBrick “script/server” command. However, if I
try to run thin:

$ thin -v
thin 1.2.5 codename This Is Not A Web Server
$ thin start

Using rails adapter
Missing the Rails 2.3.5 gem. Please gem install -v=2.3.5 rails,
update your RAILS_GEM_VERSION setting in config/environment.rb for the
Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.

This is just crazy as I certainly DO have rails 2.3.5 gem installed
(as displayed above). Now, it is true that I have ruby 1.9.0 installed
on the box as well and no 1.9 gems installed. However, I am most
certainly running everything in ruby 1.8.6.

Where else should I look to figure this problem out?

do you have your rails version set in config/environment.rb as the
error suggests? you could also freeze rails to the vendor dir.
do you get the same gems with:
$ gem list

On Jan 5, 1:17Â pm, Marli [email protected] wrote:

do you have your rails version set in config/environment.rb as the
error suggests?

Yes I do.

 you could also freeze rails to the vendor dir.

Alright, tried this for kicks. Got some interesting results:

$ rake rails:freeze:gems
(in /data/production/gfeworksheet)
Freezing to the gems for Rails 2.3.5
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/
activesupport-2.3.5’
mv activesupport-2.3.5 activesupport
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/
activerecord-2.3.5’
mv activerecord-2.3.5 activerecord
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/
actionpack-2.3.5’
mv actionpack-2.3.5 actionpack
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/
actionmailer-2.3.5’
mv actionmailer-2.3.5 actionmailer
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/
activeresource-2.3.5’
mv activeresource-2.3.5 activeresource
Unpacked gem: ‘/data/production/gfeworksheet/vendor/rails/rails-2.3.5’
cd -

Make sure script/server still works:

$ script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-01-05 13:31:35] INFO WEBrick 1.3.1
[2010-01-05 13:31:35] INFO ruby 1.8.6 (2007-09-24) [i486-linux]
[2010-01-05 13:31:35] INFO WEBrick::HTTPServer#start: pid=11456
port=3000
[2010-01-05 13:31:39] INFO going to shutdown …
[2010-01-05 13:31:39] INFO WEBrick::HTTPServer#start done.
…test requests…
^C
Exiting

Now test thin:

$ thin start

Using rails adapter
/home/kendall/inversion/config/…/vendor/rails/railties/lib/
initializer.rb:271:in require_frameworks': can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.1.0 for ["thin-1.2.5"] (RuntimeError) from /home/kendall/inversion/config/../vendor/rails/railties/ lib/initializer.rb:134:in process’
from /home/kendall/inversion/config/…/vendor/rails/railties/
lib/initializer.rb:113:in send' from /home/kendall/inversion/config/../vendor/rails/railties/ lib/initializer.rb:113:in run’
from /home/kendall/inversion/config/environment.rb:9
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:
31:in gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb: 31:in require’
from /usr/lib/ruby/gems/1.8/gems/thin-1.2.5/lib/rack/adapter/
rails.rb:42:in load_application' from /usr/lib/ruby/gems/1.8/gems/thin-1.2.5/lib/rack/adapter/ rails.rb:23:in initialize’
… 6 levels…
from /usr/lib/ruby/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:
143:in run!' from /usr/lib/ruby/gems/1.8/gems/thin-1.2.5/bin/thin:6 from /usr/bin/thin:19:in load’
from /usr/bin/thin:19

Still doesn’t work but at least now I have a stack trace with some
interesting stuff to poke around in. Thanks for the idea!

do you get the same gems with:
$ gem list

Yes.

On 05/01/2010 8:09 PM, Kendall G. wrote:

thin (1.2.5, 1.0.0)

Using rails adapter

Missing the Rails 2.3.5 gem. Please gem install -v=2.3.5 rails,
update your RAILS_GEM_VERSION setting in config/environment.rb for the
Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.

I think that the latest rack does not play too nicely with the current
version of thin. I had the same problem when I updated rack to 1.1.0.
After uninstalling rack 1.1.0 and reverting back to rack version 1.0.1
all worked OK again.

Cheers,
Gary.

Gary D. wrote:

I think that the latest rack does not play too nicely with the current
version of thin. I had the same problem when I updated rack to 1.1.0.
After uninstalling rack 1.1.0 and reverting back to rack version 1.0.1
all worked OK again.

I ran into this issue as well after installing rack 1.1.0. As noted,
reverting to 1.0.1 seems to work as a workaround. However, the real
cause seems to be that rails 2.3 is declaring that it is not compatible
with rack 1.1.0. Thin itself seems to work fine— I have a thin-sinatra
app running with rack 1.1.0 with no problems. What appears to happen on
a thin-rails stack is that thin loads rack 1.1.0 as you would expect,
but then rails (specifically actionpack) tries to load an older rack
such as 1.0.1 on top of it. So rubygems cries foul and the app fails to
start.

I believe this is best seen as an issue with rails, so I opened a ticket
here:

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3685-actionpack-235-gem-declares-incompatibility-with-rack-110

Daniel A. wrote:

Gary D. wrote:

I think that the latest rack does not play too nicely with the current
version of thin. I had the same problem when I updated rack to 1.1.0.
After uninstalling rack 1.1.0 and reverting back to rack version 1.0.1
all worked OK again.

I ran into this issue as well after installing rack 1.1.0. As noted,
reverting to 1.0.1 seems to work as a workaround. However, the real
cause seems to be that rails 2.3 is declaring that it is not compatible
with rack 1.1.0. Thin itself seems to work fine— I have a thin-sinatra
app running with rack 1.1.0 with no problems. What appears to happen on
a thin-rails stack is that thin loads rack 1.1.0 as you would expect,
but then rails (specifically actionpack) tries to load an older rack
such as 1.0.1 on top of it. So rubygems cries foul and the app fails to
start.

I believe this is best seen as an issue with rails, so I opened a ticket
here:

#3685 ActionPack 2.3.5 gem declares incompatibility with rack 1.1.0 - Ruby on Rails - rails

I had the same issue and am running Ruby 1.9.1 after updating rack to
1.1.0.
I reloaded the rails v2.3.5 gem into the rubygems for my ruby version.
cd to rails app
thin start
works just fine with rack 1.1.0, rails 2.3.5 and thin 1.2.5

evidently a the rails adapter is updated when the rails gems in
reinstalled.

/home/kendall/inversion/config/…/vendor/rails/railties/lib/
initializer.rb:271:in `require_frameworks’: can’t activate rack (~>
1.0.1, runtime) for [], already activated rack-1.1.0 for
[“thin-1.2.5”] (RuntimeError)
    from /home/kendall/inversion/config/…/vendor/rails/railties/

So I did to an upgrade of my gems today which installed rack 1.1.0. So
I’m guessing the “require_frameworks” code is trying to pull in both
1.0.1 (first) then 1.1.0, causing a conflict…?

So, I uninstalled rack 1.1.0 and retried it… works like a charm!
Problem (or at least MY problem) solved.