2013-05-06 32 views
13

因此,rails s不能與rails生成一起工作。我認爲這個問題是英雄工具帶,所以我刪除了它,但這並沒有辦法。然後我檢查了我的.zshrc文件,發現它有一個不同版本的ruby,它在PATH中調用,所以我更新了它。但是,這並沒有做到這一點。我沒有想法。有人可以幫忙嗎?rails s - > dyld:懶惰符號綁定失敗:找不到符號:_rb_intern2

#(05/6月13日@ 10:上午01時)(管理員@管理員 - 的MacBook-PRO):找不到符號:〜/桌面/劃傷 軌小號 使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/6月13日@ 10:11AM)(管理員@管理員 - 的MacBook-PRO):〜/桌面/劃傷 紅寶石-v

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

#( 05// 13 @ 10:11AM)(管理員@管理員 - 的MacBook-PRO):〜/桌面/劃傷 軌-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/[email protected]/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 
+9

嘗試rvm重新加載。然後嘗試寶石卸載sqlite3和寶石安裝sqlite3 – 2013-05-06 14:18:46

+0

omfg!有效!!!!謝謝你,肖恩。如果可能,你能解釋它爲什麼起作用嗎? – 2013-05-06 14:29:38

+1

rvm reload讓你擺脫了1/2 1.8.7/1.9.3狀態(見Frederick Cheung的回答)。我不確定這是否損壞了sqlite3 gem安裝,所以我只是讓你重新安裝它(這是給你的錯誤。) – 2013-05-06 15:05:28

回答

8

如果你使用RVM你應該讓它的路徑添加到$ PATH,而不是自己動手。實際上,它看起來像是你使用rvm的一半:你正在爲rvm安裝的ruby獲取已安裝的gem,但由於rvm ruby​​路徑在$ PATH運行的末尾,運行ruby正在拾取通過安裝的ruby一些其他的方法(可能是系統提供的一個)

其結果是你有紅寶石1.8.7試圖加載編譯爲Ruby 1.9.3的擴展,它不工作

13

的類似的錯誤形式:

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

似乎出現了很多寶石。

底層問題似乎是一個不兼容的C擴展庫(在上面的例子中,sqlite3_native.bundle)。似乎無論出於何種原因,gem都是爲舊版本的ruby而安裝的,而當前的ruby版本沒有擴展庫正在尋找的導出的C方法。

有兩種方法來解決這個

  • 卸載&重新安裝包(如在肖恩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

刪除軟件包文件,並重新安裝軟件包幫助了我。謝謝一堆! – levelone 2015-11-18 04:41:43

+0

我使用的外部gem(gemfile中的路徑)已經被編譯爲不同版本的ruby。這幫助我意識到這一點。 – 2017-05-26 13:52:04

1

更改C編譯器爲我工作。我收到了關於gpgme gem的這些錯誤之一。我的gcc二進制文件指向我安裝的gcc-4.9.2的安裝。我改變了這個在我的Mac OS 10.10(Yosemite)上使用本地clang編譯器,並且在卸載並重新安裝gem後,rails服務器正常工作。

1

我在嘗試運行rails server時遇到該錯誤,但運行bundle exec rails server時沒有錯誤。

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。錯誤消失了。

相關問題