2012-09-16 77 views
0

我在學習Rails,而且對於Macports來說還是比較新的。Macports的問題Ruby19安裝

/...config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end

我相信這句法錯誤運行一個版本的Rails,低於1.9.0證實,因爲ruby -v給我ruby 1.8.7造成的:

我爲我的項目運行rails server時收到以下錯誤。

的問題是,我敢肯定,我已經安裝了Ruby 1.9.3

我已經運行port clean ruby19和各種組合安裝Ruby 1.9.3

port install ruby19

port install ruby19 -nosuffix

兩者都給我以下錯誤:

Error: org.macports.activate for port ruby19 returned: Image error: /opt/local/bin/erb is being used by the active ruby port. Please deactivate this port first, or use 'port -f activate ruby19' to force the activation.

如果我跑port -f activate ruby19我得到這個錯誤:

---> The following versions of ruby19 are currently installed: 
--->  ruby19 @1.9.3-p194_3+doc (active) 
--->  ruby19 @1.9.3-p194_3+doc+mactk 
--->  ruby19 @1.9.3-p194_3+doc+nosuffix 
Error: port activate failed: Registry error: Please specify the full version as recorded in the port registry. 

我在哪裏何去何從?

我基本上想要最快最簡單的解決方案來啓動並運行此項目 - 我的機器上不需要多個版本的ruby。

來吧我知道我不能成爲第一個這個問題! RVM真的是人們做這件事的唯一方式嗎?

非常感謝提前!

回答

0

事實證明,我已經有一個紅寶石(1.8.7)的macports安裝。

我卸載了我所有的MacPorts ruby​​19版本sudo port uninstall ...

停用活動版本sudo port -f deactivate ruby

和安裝的1.9版本。3,無後綴

sudo port install ruby19 +nosuffix

我收到此錯誤:

Image error: /opt/local/bin/gem is being used by the active rb-rubygems port. Please deactivate this port first, or use 'port -f activate ruby19' to force the activation.

所以跑sudo port -f activate ruby19

現在,當我運行rails server我得到:

/opt/local/lib/ruby1.9/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError) 
from /opt/local/lib/ruby1.9/1.9.1/rubygems/dependency.rb:256:in `to_spec' 
from /opt/local/lib/ruby1.9/1.9.1/rubygems.rb:1231:in `gem' 
from /opt/local/bin/rails:22:in `<main>' 

個然後我更新了我的gem包,扶手:

sudo gem update --system 
sudo gem uninstall rubygems-update 
sudo gem install rails 
sudo bundle install 

結果:

Your bundle is complete! Use 'bundle show [gemname]' to see where a bundled gem is installed. 
Post-install message from rdoc: 
Depending on your version of ruby, you may need to install ruby rdoc/ri data: 

<= 1.8.6 : unsupported 
    = 1.8.7 : gem install rdoc-data; rdoc-data --install 
    = 1.9.1 : gem install rdoc-data; rdoc-data --install 
>= 1.9.2 : nothing to do! Yay! 

這裏的一個有用的討論的MacPorts和紅寶石路徑:How does MacPorts install packages? How can I activate a Ruby installation done via MacPorts?

很多人建議RVM https://rvm.io/,但對我來說我現在只需要1.9.2的運行。

2

rvm一起去,這是一個麻煩少得多,在當地工作,並更新更頻繁。你也可以使用rbenv或任何其他ruby安裝程序。節省一些時間並與這些安裝人員一起去。

+0

謝謝 - 我來看看。什麼是RVM它是macports的替代品? –

+0

rvm是一個本地ruby安裝程序,它允許您並行運行多個ruby,即,您可以選擇要在終端中運行哪一個,並且可以使用簡單的命令更改它。 – three

+0

我看到了 - 理想情況下,我想將它啓動並使用macports運行,因爲此時我的機器上還有其他所有東西。我還不需要多個版本的Ruby。如果我真的無法獲得macports版本,我會進一步調查RVM。謝謝! –