11

如果我运行rails s,我会得到:

/Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.13.2/lib/pg_ext.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

Abort trap: 6

版本:

rails -v
Rails 3.2.1
ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]

如果我使用1.9.3,为什么错误消息中提到了 ruby​​ 版本1.8.7

4

3 回答 3

13

当您最初安装 pg gem 时,它看起来像是针对 Ruby 1.8.7 编译的。简单地运行gem uninstall pg; gem install pg应该针对 Ruby 1.9.3 重新编译它。

如果您还没有,我建议您使用RVM来避免此类问题。

于 2013-04-23T11:53:28.127 回答
3

我遇到了类似的问题,运行任何东西都会bundle exec出现分段错误:

~/mayapp >bundle exec rake -T
/Users/rogermarlow/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

Abort trap: 6

我有两个问题(1)使用 1.9.3p327 而不是 1.9.3p125 和(2) GEM_HOME 环境变量指向一个现在不存在的目录。所以对我来说解决方法是:

~/myapp >rvm list

rvm rubies

=* ruby-1.9.3-p327 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

~/myapp >rvm install 1.9.3-p125
**snip**
~/myapp >rvm use 1.9.3-p125
Using /Users/rogermarlow/.rvm/gems/ruby-1.9.3-p125
Running /Users/rogermarlow/.rvm/hooks/after_use_maglev
~/myapp >echo $GEM_HOME
/Users/rogermarlow/.rvm/gems/ruby-1.9.3-p125
~/myapp ># you should check that the directory in $GEM_HOME exists, I had ...-p125@global which had been removed at some point
~/myapp >bundle install
**snip**

现在尝试bundle exec分段错误...

~/myapp >bundle exec rake -T
rake about                  # List versions of all Rails frameworks and the environment
rake assets:clean           # Remove compiled assets
rake assets:precompile      # Compile all the assets named in config.assets.precompile
**snip**
于 2013-01-20T11:00:18.333 回答
1

我不知道你的情况如何,我之前安装了 ruby​​ 1.8.7 来测试一个旧项目,然后我切换到我当前的 rails 项目文件夹,我有一个 .rvmrc 文件将我的 gemset 设置为 1.9.3@blabla . 我的 ruby​​ 和 rails 版本是正确的(1.9.3、3.2.12),但显然 Postgres 仍在尝试使用 1.8.7。并有你提到的同样的错误。

我的解决方案:

1/ cd out of the current folder project with the .rvmrc file
2/ rvm use 1.9.3 --default

然后我回到我当前的 rails 项目运行 bundle update pg,以防万一,我不知道这是否真的有任何效果,瞧,一切正常!

于 2013-02-21T13:33:08.613 回答