【问题标题】:Problems with Macports Ruby19 InstallMacports Ruby19 安装问题
【发布时间】:2012-09-16 19:09:07
【问题描述】:

我正在学习 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 真的是人们这样做的唯一方法吗?

提前非常感谢!

【问题讨论】:

    标签: ruby macports ruby-1.9.3


    【解决方案1】:

    使用rvm 会少很多麻烦,在本地工作并且更新更频繁。您还可以使用 rbenv 或任何其他 ruby​​ 安装程序。节省一些时间并使用这些安装程序。

    【讨论】:

    • 谢谢 - 我会看看。什么是 RVM,它是 macports 的替代品吗?
    • rvm 是一个本地 ruby​​ 安装程序,可让您并行运行多个 ruby​​,即您选择要立即在终端中运行的一个,并允许您使用简单的命令进行更改。
    • 我明白了 - 理想情况下,我希望通过 macports 启动并运行它,因为这就是我目前在我的机器上拥有其他所有东西的方式。我还不需要多个版本的 Ruby。如果我真的无法让 macports 版本正常工作,我会进一步调查 RVM。谢谢!
    • 当然,没关系。我以为你选择 Macports 只是作为安装 Ruby 的一种方式。这对它的作用有好处!
    【解决方案2】:

    原来我已经安装了 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。

    【讨论】:

      猜你喜欢
      • 2015-07-09
      • 2011-03-11
      • 2013-08-19
      • 2012-08-06
      • 1970-01-01
      • 2012-03-04
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多