13

所以 rails s 不能与 rails generate 一起工作。我认为问题出在 heroku 工具带上,所以我删除了它,但这并没有解决问题。然后我检查了我的 .zshrc 文件,发现它在 PATH 中调用了不同版本的 ruby​​,所以我更新了它。然而这并没有做到。我没主意了。有人可以帮忙吗?

#( 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

宝石文件:

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
4

5 回答 5

15

表格的类似错误:

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

似乎出现了很多宝石。

根本问题似乎是一个不兼容的 C 扩展库(在上述情况下,sqlite3_native.bundle)。似乎无论出于何种原因,gem 是为旧版本的 ruby​​ 安装的,而当前的 ruby​​ 版本没有扩展库正在寻找的导出 C 方法。

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

  • 卸载并重新安装软件包(正如上面 Shawn Balesstracci 的评论中所指出的)。在上述情况下,我们可以推断该包是 sqlite3:

    gem uninstall {package}; gem install {package}

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

  • 删除捆绑文件并重新安装包。查看错误信息:引用自:/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}

于 2013-08-27T19:52:39.430 回答
8

如果您使用 rvm,您应该让它将其路径添加到 $PATH 而不是自己做。实际上,您似乎使用了一半 rvm:您正在为 rvm 安装的 ruby​​ 安装 gem,但是由于 rvm ruby​​ 路径位于 $PATH 运行的末尾,因此ruby正在选择通过一些安装的 ruby其他方法(也许系统提供了一个)

结果,您让 ruby​​ 1.8.7 尝试加载为 ruby​​ 1.9.3 编译的扩展,这不起作用

于 2013-05-06T14:21:14.220 回答
1

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

于 2015-05-08T21:26:12.500 回答
1

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

于 2016-04-06T17:24:37.360 回答
0

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

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

rvm install 2.2
rvm use 2.2

现在您必须重新安装所有 gem:

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。错误消失了。

于 2016-11-28T23:49:48.647 回答