【问题标题】:Install Rails 3 in Windows在 Windows 中安装 Rails 3
【发布时间】:2011-01-07 10:24:04
【问题描述】:

我的 ruby​​ 环境已启动并正在运行(通过 RubyInstaller 获得)。 每当我尝试使用以下命令安装 rails 时:

gem install --http-proxy http://localhost:3128 rails --debug -V

我开始收到错误,因此无法安装它:

Exception `NameError' at C:/Ruby192/lib/ruby/1.9.1/rubygems/command_manager.rb:164 - uninitialized constant Gem::Commands::InstallCommand
Exception `NameError' at C:/Ruby192/lib/ruby/1.9.1/syck/tag.rb:81 - method `yaml_as' not defined in Module
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
Exception `Interrupt' at <internal:lib/rubygems/custom_require>:29 -
ERROR:  Loading command: install (Interrupt)

        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/package.rb:92:in `<top (required)>'
        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/format.rb:9:in `<top (required)>'
        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:10:in `<top (required)>'

        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/dependency_installer.rb:3:in `<top (required)>'
        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/commands/install_command.rb:4:in `<top (required)>'
        <internal:lib/rubygems/custom_require>:29:in `require'
        <internal:lib/rubygems/custom_require>:29:in `require'
        C:/Ruby192/lib/ruby/1.9.1/rubygems/command_manager.rb:170:in `rescue in load_and_instantiate'

[..]

有人可以帮忙吗?谢谢

【问题讨论】:

标签: ruby-on-rails ruby


【解决方案1】:

省略 --http-proxy 部分并重试, 我也遇到过很多问题。

在 Windows 系统属性中的系统变量中添加 http_proxy 在 XP 中:右键单击“开始”菜单中的“我的电脑”,然后单击“高级”->“环境变量”。

【讨论】:

  • 奇怪,因为我今天早上刚刚用 ruby​​installer 重新安装了 Ruby 1.9,然后也安装了 Rails,它也能正常工作.. 我使用的确切命令:gem install rails --no-ri - -no-rdoc 也许还有一点:你有没有解压并使用 DevKit?含义:转到命令提示符,cd 进入 DevKit 文件夹并输入 devkitvars.bat?也许这会有所不同..
【解决方案2】:

试试这个: gem install rails -p user@pass:proxy-url

也看this

希望这会有所帮助。

【讨论】:

    【解决方案3】:

    这不是问题的直接答案,但在尝试过 InstantRails、RubyStack 等方法后,我发现这些只是要维护的额外层 - 我从来不知道幕后发生了什么。此外,我必须等待项目维护者发布更新才能获得最新和最好的。最后,这些绝不代表生产环境,这意味着我必须在生产时学习一套全新的优化。

    以下是一些想法/建议:

    您是否计划在 Windows 环境中进行部署?如果没有,我会建议/推荐设置运行 Linux 的虚拟机(例如 VirtualBox)(Ubuntu 是我的首选)。您可以轻松运行 512MB 或更少的 RoR + db 环境。

    然后,您可以通过启用 Samba(用于开发目的)从您的 Windows 机器访问文件系统,这样您就可以使用您最喜欢的 Windows IDE 工具。要启动/停止服务器、运行迁移等,只需使用终端到实例。

    这种方法有很多好处:

    1. Ruby 和 Rails 在 Linux 上明显更快
    2. 假设这是您的目标部署环境,这将是从开发到生产的轻松过渡
    3. 将 Ruby 和 Rails 与 Windows 分开也有助于保持 Windows 运行干净。更低的 RAM 使用率,更干净的磁盘,您可以根据需要通过启动/关闭 VM 来打开/关闭 RoR 实例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-26
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多