【问题标题】:therubyracer gem on windows窗户上的 therubyracer gem
【发布时间】:2011-09-15 10:25:03
【问题描述】:

几个星期以来,我一直在 Windows 上进行和平开发,没有添加任何 gem,今天我决定进行捆绑更新,但我无法通过这个名为 therubyracer 的 gem。我已经安装了 devkit,它正在按照文档的验证程序运行。

我的问题是:有没有办法在 Windows 上安装这个 gem?

rails 3.1 是否需要这个 gem,这就是为什么现在我做了一个包更新它被“滑入”到 rails 3.0.8 作为未来 3.1 迁移的早期启动的姿态?

编辑包括 Gemfile 和 Gemfile.lock

# Gemfile
# source 'http://rubygems.org'
source :rubygems

gem 'rails'
gem 'rake', '0.8.7'
gem 'youtube_it'
gem 'panda'
gem "nifty-generators"
# gem "mongoid", "2.0.0.rc.7"
gem "mongoid"
gem "mongoid-eager-loading"
# gem 'mongoid_search'
gem "bson_ext", ">1.1.5"
gem 'devise'
gem 'cancan'
gem 'hirb'
# gem 'heroku'
gem 'rest-client'
gem 'less' # needs the more plugin
# gem 'hash_extension'
gem 'aws-s3', :require => 'aws/s3' # s3.rb
gem 'jquery-rails', ">= 0.2.7" # rails g jquery:install
# gem 'mongrel', ">= 1.2.0.pre2"
gem 'delayed_job'
gem 'delayed_job_mongoid'
gem 'kaminari'



# Gemfile.lock
GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.8)
      actionpack (= 3.0.8)
      mail (~> 2.2.19)
    actionpack (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.8)
      activesupport (= 3.0.8)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.8)
      activemodel (= 3.0.8)
      activesupport (= 3.0.8)
    activesupport (3.0.8)
    arel (2.0.10)
    aws-s3 (0.6.2)
      builder
      mime-types
      xml-simple
    bcrypt-ruby (2.1.4-x86-mingw32)
    bson (1.3.1)
    bson_ext (1.3.1)
    builder (2.1.2)
    cancan (1.6.5)
    daemons (1.1.3)
    delayed_job (2.1.4)
      activesupport (~> 3.0)
      daemons
    delayed_job_mongoid (1.0.2)
      delayed_job (~> 2.1.1)
      mongoid (~> 2.0.0.rc)
    devise (1.3.4)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    hirb (0.4.5)
    i18n (0.5.0)
    jquery-rails (1.0.10)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.5.2)
    kaminari (0.12.4)
      rails (>= 3.0.0)
    less (1.2.21)
      mutter (>= 0.4.2)
      treetop (>= 1.4.2)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    mongo (1.3.1)
      bson (>= 1.3.1)
    mongoid (2.0.2)
      activemodel (~> 3.0)
      mongo (~> 1.3)
      tzinfo (~> 0.3.22)
    mongoid-eager-loading (0.3.1)
    mutter (0.5.3)
    nifty-generators (0.4.6)
    oauth (0.4.4)
    orm_adapter (0.0.5)
    panda (1.4.2)
      json
      rest-client
      ruby-hmac (>= 0.3.2)
    polyglot (0.3.1)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.8)
      actionmailer (= 3.0.8)
      actionpack (= 3.0.8)
      activerecord (= 3.0.8)
      activeresource (= 3.0.8)
      activesupport (= 3.0.8)
      bundler (~> 1.0)
      railties (= 3.0.8)
    railties (3.0.8)
      actionpack (= 3.0.8)
      activesupport (= 3.0.8)
      rake (>= 0.8.7)
      thor (~> 0.14.4)
    rake (0.8.7)
    rest-client (1.6.1)
      mime-types (>= 1.16)
    ruby-hmac (0.4.0)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.28)
    warden (1.0.4)
      rack (>= 1.0)
    xml-simple (1.0.16)
    youtube_it (1.4.2)
      builder
      oauth (>= 0.4.4)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  aws-s3
  bson_ext (> 1.1.5)
  cancan
  delayed_job
  delayed_job_mongoid
  devise
  hirb
  jquery-rails (>= 0.2.7)
  kaminari
  less
  mongoid
  mongoid-eager-loading
  nifty-generators
  panda
  rails
  rake (= 0.8.7)
  rest-client
  youtube_it

【问题讨论】:

  • 您是否也在 Windows 上部署该应用程序?如果没有(例如,您正在部署到 Heroku),那么您可以在 Windows 环境中删除对 therubyracer 的依赖。如果这是您的场景,很高兴扩展。
  • @Dominic Sayers -- 不,不是在 Windows 上,但在 Heroku 上是。我的猜测是,如果我不直接与根本无法在 Windows 上安装的 gem 交互,但 Heroku 是 Linux,所以应该没问题。所以我不完全知道如何将它从 Rails 应用程序的依赖项中排除。我的意思是,我从来没有在我的 Gemfile 中指定它。有一天它突然出现在我的“捆绑更新”中。谢谢!

标签: ruby-on-rails rubygems bundler devkit


【解决方案1】:

不,据我所知,目前无法在 Windows 上安装此 gem。问题是目前没有针对Windows的libv8 gem的预编译版本,源码版本只兼容*nix。不一定非要这样,它只需要有人花时间让编译工作在 Windows 上工作。 https://github.com/cowboyd/libv8

也就是说,Windows 应该附带一个 JScript,即 Microsoft JavaScript 运行时,Rails(通过execjs)会自动检测和使用它,因此您应该能够删除对 therubyracer 的依赖。

作为该 gem 的维护者,这当然会让我感到难过,但它应该能让你走上自己的道路。

【讨论】:

  • 哦,哇,很高兴你(维护者)回答我的问题谢谢!! -- 感谢 execjs 的提示,我会查一下。抱歉打扰了,您知道如何在 Rails 中找到 gem 依赖项吗?
  • Nik,如果您正在做的只是使用带有咖啡脚本的 vaniall Rails 3.1 资产管道,那么您应该能够只使用 execjs gem 来委托检测您在 Windows 上并使用 Microsoft JScript 解释器。那么你根本不需要在你的 Gemfile 中包含 therubyracer。
  • 我已经能够通过“bundle update development”更新 Gemfile -- 原因:我有这一行,它的范围是安装 therubyracer 的 Gemfile 的 :production 组,因为我在某处读到它Heroku 需要(是否仍然需要,我不确定)所以每次我执行简单的“捆绑更新”时都会抛出相同的错误,但如果我执行上述“捆绑更新开发”,它就可以工作。 --- 我已经阅读了相当多的博客文章,这些文章基本上重申了你所说的话,execjs 应该启动并告诉 rails 使用本机 MS 引擎,但不是真的......
  • 您好,补充一点:您可以在 Gemfile 中写入gem 'therubyracer', :platform => :ruby,这样therubyracer 只能安装在 linux 和 OSX 上,而不是 Windows。
  • 内森,这是真的,但在 cygwin 下,你在 windows 中并且 :platform => :ruby 没有效果
【解决方案2】:

所有这些问题的原因是 therubyracer-0.11.0beta1-x86-mingw32.gem 和 v8.dll。

我已经编译好必要的dll和gem文件并上传到github了。

下载软件包并按照说明进行操作。

https://github.com/eakmotion/therubyracer_for_windows

【讨论】:

  • 我尝试了您在说明中所说的内容,但收到消息已成功安装 therubyracer-0.11.0beta1-x86-mingw32 1 个 gem 安装了 therubyracer-0.11.0beta1-x86-mingw32 的 ri 文档。 .. 为 ruby​​racer-0.11.0beta1-x86-mingw32 安装 RDoc 文档...并将 dll 文件复制到 bin 文件夹,重新启动机器 3 次。我在 Windows 7 上运行。仍然捆绑安装显示错误。
  • 将 less-rails gem 放入你的 bundle 文件并运行 bundle install ex :- gem 'less-rails' gem 'therubyracer'
  • @Hiran 我在我的 C:\RailsInstaller\Ruby1.9.3\bin 下尝试过,但它不起作用..让我知道如何修复它..我仍在努力消除这个 therubyracer 问题
  • 链接中的说明在 Windows7 64 位上完美运行。谢谢!
  • 获取v8_context.rb:2:in require': cannot load such file -- v8 (LoadError) on running rails server。此外,我在 Gemfile.lock 中没有看到 libv8
【解决方案3】:

build for windows。可以gem install therubyracer-0.11.0beta1-x86-mingw32.gem手动下载安装。

【讨论】:

  • ERROR: Could not find a valid gem 'therubyracer-0.11.0beta1-x86-mingw32.gem' (>= 0) in any repository
  • 注意: 您必须将 gem 下载到本地目录并在本地引用 下载链接:github.com/downloads/stereobooster/therubyracer/…
  • @blockloop 你能告诉我你是怎么做到的吗?我克隆了目录,按照说明进行操作。没用。然后我读了你的东西,并在 Gemfile 中指出了我保存 therubyracer-0.11.0beta1-x86-mingw32.gem 的路径。但是当我运行 bundle 时它没有检测到它。
【解决方案4】:

这基本上就是 Nik 所做的,我相信:

在您的 Gemfile 中,将 TheRubyRacer gem 隔离到生产环境,如下所示:

group :production do
  gem 'therubyracer-heroku', :platform => :ruby
end

在您的开发环境中,而不是普通的bundle install

bundle install --without production

或者,正如 Nik 所建议的,bundle install development。当您部署到 Heroku 时,它将安装 gem,因为它是生产环境。

Rails 专家:请提出修改建议以减少麻烦。

【讨论】:

  • 是的,确实如此。过去几周我一直在使用的 Gemfile 看起来很相似,我确实进行了“捆绑安装开发”以避免任何错误消息。我确实希望 Rails 核心团队能够对 Rails 进行调整,以便使三个主要平台上的通用 Rails 安装/使用基本相同。感谢您一直回到这个问题多米尼克
  • 你可以在你的 Gemfile 中添加gem 'therubyracer', :platform => :ruby,这样therubyracer 只安装在 linux 和 OSX 上,而不是 Windows
  • 感谢 nathan.f77 的建议。我已经按照你的建议编辑了我的答案。
【解决方案5】:

要回答您关于 Rails 3.1 的部分问题,以下是交易...

Rails 3.1 当前使用需要在机器上安装 javascript 运行时的 gem。在 Mac 上,您通常不必担心这一点,因为它已经有一个,但 Linux(我认为 Windows 也是)您需要安装一个。因此,有时会安装 therubyracer,或者有时会安装 node 或 nodejs,因为它们提供了这些。

然而,Rails 的一位主要人员表示,他们计划在 Rails 3.1 最终版本发布之前修复该依赖关系,因此希望这会发生并且依赖关系将会消失。

【讨论】:

  • 我看到 Rails 3.1 确实/将需要这可能是资产打包的事情。既然你提到了 nodejs,我听说他们可能有一个 windows 版本,我只是去他妈的先把它安装在我的电脑上,看看 rails 是否“检测到" 它并忽略安装 therubyracer (暂时)。谢谢
猜你喜欢
  • 2020-10-06
  • 1970-01-01
  • 1970-01-01
  • 2012-03-25
  • 2014-07-27
  • 2016-02-02
  • 2020-05-06
  • 1970-01-01
  • 2023-04-09
相关资源
最近更新 更多