Macports Ruby19安装问题

时间:2012-09-16 19:09:07

标签: ruby macports ruby-1.9.3

我正在学习Rails并且对Macports来说还是个新手。

我为项目运行rails server时收到以下错误:

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

我认为这种语法错误是由于运行版本低于1.9.0的Rails确认的,因为ruby -v给了我ruby 1.8.7

问题是我确定我已经安装了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真的是人们这样做的唯一方式吗?

非常感谢提前!

2 个答案:

答案 0 :(得分:2)

使用rvm,这不是一件麻烦,在本地工作并且更频繁地更新。您也可以使用rbenv或其他任何ruby安装程序。节省一些时间并与这些安装人员一起使用。

答案 1 :(得分:0)

事实证明我已经安装了一个ruby(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包和rails:

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和ruby路径的有用讨论:How does MacPorts install packages? How can I activate a Ruby installation done via MacPorts?

很多人推荐RVM https://rvm.io/,但对我来说,我现在只需要运行1.9.2。