rails s - > dyld:惰性符号绑定失败:未找到符号:_rb_intern2

时间:2013-05-06 14:10:54

标签: ruby-on-rails

所以rails并不跟rails生成一起工作。我认为问题是heroku toolbelt,所以我删除了它,但是没有做到这一点。然后我检查了我的.zshrc文件,看到它有一个不同版本的ruby,它在PATH中调用,所以我更新了。然而,这没有做到。我没有想法。有人可以帮忙吗?

#(05/06/13 @ 10:01AM)(admin @ Administrators-MacBook-Pro):〜/ desktop / scratch        rails s     dyld:惰性符号绑定失败:未找到符号:_rb_intern2       /Users/admin/.rvm/gems/ruby-1.9.3-p392/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle:从引用       期望:平面命名空间

dyld: Symbol not found: _rb_intern2
  Referenced from: /Users/admin/.rvm/gems/ruby-1.9.3-p392/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle
  Expected in: flat namespace

[1]    69741 trace trap  rails s

#(05/06/13 @ 10:02AM)(admin @ Administrators-MacBook-Pro):〜/ desktop / scratch        rvm list default

Default Ruby (for new shells)

   ruby-1.9.3-p392 [ x86_64 ]

#(05/06/13 @ 10:11AM)(admin @ Administrators-MacBook-Pro):〜/ desktop / scratch    ruby -v

ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

#(05/06/13 @ 10:11AM)(admin @ Administrators-MacBook-Pro):〜/ desktop / scratch    rails -v

Rails 3.2.12

的Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.12'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
# gem 'pg'
gem "bootstrap-sass", ">= 2.3.0.0"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

.zshrc文件:

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="junkfood"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"

# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export PATH=//opt/local/bin:/opt/local/sbin://usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/opt/local/bin:/opt/local/sbin:/Users/admin/.rvm/gems/ruby-1.9.3-p392/bin:/Users/admin/.rvm/gems/ruby-1.9.3-p392@global/bin:/Users/admin/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/admin/.rvm/bin:/usr/local/mysql/bin:/Users/admin/.rvm/bin

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

5 个答案:

答案 0 :(得分:14)

形式的类似错误:

Symbol not found: {some-symbol}
Referenced from: /path/to/some/file.bundle
Expected in: flat namespace

似乎突然出现了许多宝石。

底层问题似乎是一个不兼容的C扩展库(在上面的例子中,sqlite3_native.bundle)。似乎无论出于何种原因,gem都安装了旧版本的ruby,而当前的ruby版本没有扩展库正在寻找的导出C方法。

有两种方法可以解决这个问题

  • 卸载&重新安装包(正如上面Shawn Balestracci的评论中所指出的那样)。在上面的例子中,我们可以推断出包是sqlite3:

    gem uninstall {package}; gem install {package}

OR(不太可取,但如果上述方法由于某种原因失败,则可能有用):

  • 删除捆绑包文件并重新安装包。查看错误消息: 参考自:/Users/admin/.rvm/gems/ruby-1.9.3-p392/gems/sqlite3-1.3.7/lib/sqlite3/sqlite3_native.bundle,我们只需要:

    rm {path-to-bundle-file}; gem install {package}

答案 1 :(得分:8)

如果您使用rvm,您应该让它将路径添加到$ PATH而不是自己动手。事实上,你似乎有一半使用rvm:你正在为rvm安装的ruby安装宝石,但由于rvm ruby​​路径在$ PATH结束时运行ruby正在恢复通过其他方法安装的ruby(可能是系统提供的方法)

结果你得到ruby 1.8.7试图加载为ruby 1.9.3编译的扩展,这不起作用

答案 2 :(得分:1)

更改C编译器对我有用。我收到了关于gpgme gem的这些错误之一。我的gcc二进制文件指向我安装的gcc-4.9.2的安装。我将其更改为在Mac OS 10.10(Yosemite)上使用本机clang编译器,并且在卸载并重新安装gem之后rails服务器工作正常。

答案 3 :(得分:1)

我尝试运行rails server时遇到了这个错误,但是当我运行bundle exec rails server时没有错误。

答案 4 :(得分:0)

这对我的Ruby安装而不是实际页面来说是一个问题。我做了什么来解决它:

我正在使用RVM。所以首先我将Ruby从2.1.1更新为2.2:

rvm install 2.2
rvm use 2.2

现在你必须重新安装所有宝石:

gem install bundler
bundle install

接下来更新你的nginx.conf:

passenger_root /usr/local/opt/passenger/libexec/src/ruby_supportlib/phusion_passenger/locations.ini;
    passenger_ruby /Users/admin/.rvm/gems/ruby-2.2.4/wrappers/ruby;

您对这些的价值可能会有所不同。

然后重启Nginx。错误消失了。