rvm conflit with sqlite3

2019-04-19 07:39发布

问题:

$: /Users/dev/.rvm/gems/ruby-1.9.2-head@rails3/gems/sqlite3-ruby-1.3.1/lib/sqlite3/sqlite3_native.bundle: [BUG] Segmentation fault ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap

It's seem that ruby is not the correct version (1.8.7) but :

$: ruby - v
$: ruby 1.9.2dev (2010-07-15 revision 28653) [x86_64-darwin10.4.0]



$: gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.0.beta4, 3.0.0.beta3)
actionpack (3.0.0.beta4, 3.0.0.beta3)
activemodel (3.0.0.beta4, 3.0.0.beta3)
activerecord (3.0.0.beta4, 3.0.0.beta3)
activeresource (3.0.0.beta4, 3.0.0.beta3)
activesupport (3.0.0.beta4, 3.0.0.beta3)
arel (0.4.0, 0.3.3)
builder (2.1.2)
bundler (0.9.26)
erubis (2.6.6)
i18n (0.4.1, 0.3.7)
mail (2.2.5)
memcache-client (1.8.5)
mime-types (1.16)
polyglot (0.3.1)
rack (1.1.0)
rack-mount (0.6.9)
rack-test (0.5.4)
rails (3.0.0.beta4, 3.0.0.beta3)
railties (3.0.0.beta4, 3.0.0.beta3)
rake (0.8.7)
rdoc (2.5.9)
sqlite3-ruby (1.3.1)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.13.8)
treetop (1.4.8)
tzinfo (0.3.22)
will_paginate (3.0.pre)

more info :

$: ~ dev$ ruby -v
ruby 1.9.2dev (2010-07-15 revision 28653) [x86_64-darwin10.4.0]
$ :~ dev$ rails -v



/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
from /usr/bin/rails:18

Any ideas ?

Thanks very much :)

回答1:

I don't know how this has happened in your case but it looks to me that Rails has tried to run with your system installed Ruby but is loading gems from a 1.9.2 load path. Very odd.

You see the correct Ruby version in your shell (RVM has precedence in the local path) but that's not apparently what Rails is being started with.

Check to see you how you are starting Rails and that you don't have paths or links or aliases messed up between Ruby versions



回答2:

Had the same issue after moving to 1.9.2p0, but restarting the console on Snow Leopard did the trick. Seems rvm might have gotten confused.



回答3:

Same problem for me on Snow Leopard; even though under rvm 1.9.2@rails3, I can see correct rails version number.

I have to use following command to use rails command:

ruby which rails g scaffold User name:string bio:text

Any solution?

I've finally found the reason. Looks like gem install rails is not managed to install the proper binary for rails in rvm. And rails is still references /usr/bin/rails, which have a #! line point to System ruby.

You can see it with:

head -1 `which rails`

which returns:

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Change that to:

#!/usr/bin/env ruby

will fix the problem. I don't know if this problem affect other executable scripts gem installs, but why gem not install rails to rvm's own bin path is a mystery to me. Anyway, this workaround do the dirty for me.



回答4:

I Had the same problem when using ree-1.8.7-2011.03. (Ruby enterprise Edition)

I uninstalled the sqlite3 gems then I ran:

gem install sqlite3

and it worked. Note that the sqlite3-ruby gem now recommends to use 'sqlite3' now.



回答5:

You might need to run

rvm reload


回答6:

Same problem after a bunch of updates (rvm to 1.5.2 and ruby to 1.9.2-p180)

Console restart did not work for me, updating to rails 3.0.6 changed the error to a seg error of mysql2 instead of sqlite3, re-installing mysql2 did the trick for me finally.

Regards Michael



回答7:

I encountered this exact error in zsh and MacVim, and eventually tracked it back to this RVM issue. The solution was to move the RVM sourcing I had in .zshrc to .zshenv. Worked immediately. Just posting on the off chance someone stumbles across this the way I did.



回答8:

There is a known issue with zsh, rvm and vim.

The latest solution is to set the shell to sh in your .vimrc

set shell=sh

This blog has all the solutions listed