WEBrick won't use correct Ruby version with RVM

Ok, so I realised the hard way that 1.9.1 is just too close to the
edge, especially in combination with Rails 3. I installed RVM and
1.8.7 which seems to work, but whenever I start WEBrick it still
insists on using 1.9.1 which causes all sorts of strange problems and
exceptions.

[email protected]:~/rails/TestProject$ rvm use 1.8.7
Using ruby 1.8.7 p249
[email protected]:~/rails/TestProject$ rails server -p 3001
=> Booting WEBrick
=> Rails 3.0.0.beta application starting in development on
http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-03-31 13:50:09] INFO WEBrick 1.3.1
[2010-03-31 13:50:09] INFO ruby 1.9.1 (2009-12-07) [i486-linux]
[2010-03-31 13:50:19] INFO WEBrick::HTTPServer#start: pid=6260
port=3001

and then

/home/bob/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-3.0.0.beta/lib/
active_record/connection_adapters/mysql_adapter.rb:598: [BUG] unknown
type 0x22 (0xc given)
ruby 1.9.1p376 (2009-12-07 revision 26041) [i486-linux]

What to do now?

My bet is that you’re environment doesn’t have a rails binary and it
is finding the first one it can, which happens to be 1.9.1.

Does the same thing happen when you do:

∴ ./script/rails server

Which will be sure to use the Rails version bundler bundled for the
app with the current Ruby?

You can also check to make sure you’re 1.8.7 env is correct using rvm info

~Wayne

Also, you can check to see where the rails binary in your path is:

∴ which rails

And see what ruby it is pointed at:

∴ head -n 1 $(which rails)

~Wayne

On Mar 31, 2:30Â pm, Cogaidhean [email protected] wrote:

Also, you can check to see where the rails binary in your path is:

∴ which rails

And see what ruby it is pointed at:

∴ head -n 1 $(which rails)

 ~Wayne

Many thanks for your suggestions.

[email protected]:~/rails/TestProject$ head -n 1 $(which rails)
#!/home/bob/.rvm/rubies/ruby-1.8.7-p249/bin/ruby

On Mar 31, 3:14Â pm, mikrogroove [email protected] wrote:

#!/home/bob/.rvm/rubies/ruby-1.8.7-p249/bin/ruby
Also:

[email protected]:~/rails/TestProject$ rvm info
system:
uname: “Linux silicon 2.6.31-14-generic-pae #48-Ubuntu SMP
Fri Oct 16 15:22:42 UTC 2009 i686 GNU/Linux”
shell: “bash”
version: “4.0.33(1)-release”

ruby:
interpreter: “ruby”
version: “1.8.7”
date: “2010-01-10”
platform: “i686-linux”
patchlevel: “2010-01-10 patchlevel 249”
full_version: “ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]”

homes:
gem: “/home/bob/.rvm/gems/ruby-1.8.7-p249”
ruby: “/home/bob/.rvm/rubies/ruby-1.8.7-p249”

binaries:
ruby: “/home/bob/.rvm/rubies/ruby-1.8.7-p249/bin/ruby”
irb: “/home/bob/.rvm/rubies/ruby-1.8.7-p249/bin/irb”
gem: “/home/bob/.rvm/rubies/ruby-1.8.7-p249/bin/gem”
rake: “/home/bob/.rvm/gems/ruby-1.8.7-p249/bin/rake”

environment:
GEM_HOME: “/home/bob/.rvm/gems/ruby-1.8.7-p249”
GEM_PATH: “/home/bob/.rvm/gems/ruby-1.8.7-p249:/home/bob/.rvm/
gems/ruby-1.8.7-p249%global”
BUNDLE_PATH: “/home/bob/.rvm/gems/ruby-1.8.7-p249”
MY_RUBY_HOME: “/home/bob/.rvm/rubies/ruby-1.8.7-p249”
IRBRC: “/home/bob/.rvm/rubies/ruby-1.8.7-p249/.irbrc”

On Mar 31, 4:12 pm, Cogaidhean [email protected] wrote:

Other than you not being on the latest RVM the environment looks
healthy from RVM’s standpoint.

Thanks for looking at this Wayne, it’s pretty weird since everything
else seems perfectly ok - I’m at a loss as to what to do to move
forward and get things working again! Start from scratch?

Other than you not being on the latest RVM the environment looks
healthy from RVM’s standpoint.

On Apr 1, 12:09 am, mikrogroove [email protected] wrote:

On Mar 31, 4:12 pm, Cogaidhean [email protected] wrote:

Other than you not being on the latest RVM the environment looks
healthy from RVM’s standpoint.

Thanks for looking at this Wayne, it’s pretty weird since everything
else seems perfectly ok - I’m at a loss as to what to do to move
forward and get things working again! Start from scratch?

I tried installing Mongrel instead and things got even weirder…

[email protected]:~/rails/TestProject$ rvm use 1.8.7
Using ruby 1.8.7 p249
[email protected]:~/rails/TestProject$ rvm gem install mongrel
ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
mongrel is not installed, installing…
mongrel installed.
[email protected]:~/rails/TestProject$ mongrel_rails start -p 3001
** Starting Mongrel listening at 0.0.0.0:3001
** Starting Rails with development environment…
/home/bob/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/
active_support/dependencies.rb:167:in `require’: no such file to load
– dispatcher (LoadError)

…etc

My advice would be to use bundler.

Make sure you’re gems are listed in your Gemfile

Do a “ruby -S bundle install”

Then a “ruby -S bundle exec rails server”

At that point you can be reasonably sure you’re not mixing multiple
environments together.

On Wed, Mar 31, 2010 at 7:54 AM, mikrogroove [email protected]
wrote:

=> Rails 3.0.0.beta application starting in development on
/home/bob/.rvm/gems/ruby-1.8.7-p249/gems/activerecord-3.0.0.beta/lib/
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Michael G.
http://blog.michaelgreenly.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs