使用 less (2.2.1) 会引发需要 therubyracer 的错误(无法在 Windows 上安装 therubyracer)

Posted

技术标签:

【中文标题】使用 less (2.2.1) 会引发需要 therubyracer 的错误(无法在 Windows 上安装 therubyracer)【英文标题】:Using less (2.2.1) raises an error requiring therubyracer (can't install therubyracer on windows) 【发布时间】:2012-08-31 22:27:48 【问题描述】:

我一直在努力让 twitter-bootstrap-rails gem 在我的 Windows 机器上运行,但在尝试安装 'therubyracer' gem 时遇到了错误,它是旧版本的 less gem 的依赖项。

我认为升级到不依赖于 therubyracer 的 less 2.2.1 但是尽管如此,它似乎认为我仍然需要安装 therubyracer。这是我尝试启动 rails server 'rails s' 时得到的错误输出。

$ rails s
[WARNING] Please install gem 'therubyracer' to use Less.
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- v8 (LoadError)
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less/java_script/v8_context.rb:2:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less/java_script.rb:9:in `default_context_wrapper'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less/java_script.rb:17:in `context_wrapper'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less/loader.rb:10:in `initialize'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less.rb:14:in `new'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less.rb:14:in `<module:Less>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.2.2/lib/less.rb:9:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2.3/lib/less/rails.rb:6:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-rails-2.2.3/lib/less-rails.rb:1:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/twitter-bootstrap-rails-2.1.2/lib/twitter-bootstrap-rails.rb:9:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
    from C:/Sites/alliance/config/application.rb:9:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

这是我的 GemfileGemfile.lock 文件。谁能帮我弄清楚如何告诉我的应用它不需要安装“therubyracer”?

---- Gemfile ----

source 'https://rubygems.org'

gem 'rails',   '~> 3.2.3'
gem 'jquery-rails'
gem 'haml-rails'
gem 'simple_form'
gem 'decent_exposure'
gem "devise", :git => "git://github.com/plataformatec/devise.git"
gem 'cancan'
gem 'prawn'
gem 'ransack'
gem 'eventmachine', '= 1.0.0.rc.4'
gem 'therubyracer', :platforms => :ruby

group :assets do
  gem 'execjs'
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'bootstrap-sass'
  gem 'twitter-bootstrap-rails' 
  gem 'uglifier', '>= 1.0.3'
end

group :development, :test do
  gem 'debugger'
  gem 'rails_best_practices'
  gem 'factory_girl_rails', '~> 2.0'
  gem 'sqlite3'
  gem 'simplecov', require: false
  gem 'rspec-rails'
  gem 'rspec-instafail'
  gem 'rspec-steps'
  gem 'factory_girl_rails', '~> 2.0'
  gem "capybara"
  gem "selenium-webdriver"
  gem 'launchy' # provides save_and_open_page
  gem 'fuubar'

  gem 'database_cleaner'
  gem 'rantly'
  gem 'heroku'
  gem 'rb-fsevent' #, :require => false if RUBY_PLATFORM =~ /darwin/i
  gem 'guard-rspec'
end

group :production do
  gem 'mysql2'
  gem 'thin'
  gem 'pg'
end

---- Gemfile.lock ----

GIT
  remote: git://github.com/plataformatec/devise.git
  revision: f7dd59839cd39ed3c57948d37e8a95c697c14647
  specs:
    devise (2.1.2)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)

GEM
  remote: https://rubygems.org/
  specs:
    Ascii85 (1.0.1)
    actionmailer (3.2.8)
      actionpack (= 3.2.8)
      mail (~> 2.4.4)
    actionpack (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.3)
    activemodel (3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
    activerecord (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
    activesupport (3.2.8)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    addressable (2.3.2)
    arel (3.0.2)
    awesome_print (1.0.2)
    bcrypt-ruby (3.0.1-x86-mingw32)
    bootstrap-sass (2.1.0.0)
    builder (3.0.1)
    cancan (1.6.8)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.5)
      ffi (~> 1.0, >= 1.0.6)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.3.3)
    colored (1.2)
    columnize (0.3.6)
    commonjs (0.2.6)
    daemons (1.1.9)
    database_cleaner (0.8.0)
    debugger (1.2.0)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.1.1)
      debugger-ruby_core_source (~> 1.1.3)
    debugger-linecache (1.1.2)
      debugger-ruby_core_source (>= 1.1.1)
    debugger-ruby_core_source (1.1.3)
    decent_exposure (1.0.2)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    eventmachine (1.0.0.rc.4-x86-mingw32)
    excon (0.16.2)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (3.0.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (2.0.0)
      factory_girl (~> 3.0.0)
      railties (>= 3.0.0)
    ffi (1.1.5)
    fuubar (1.0.0)
      rspec (~> 2.0)
      rspec-instafail (~> 0.2.0)
      ruby-progressbar (~> 0.0.10)
    guard (1.3.2)
      listen (>= 0.4.2)
      thor (>= 0.14.6)
    guard-rspec (1.2.1)
      guard (>= 1.1)
    haml (3.1.7)
    haml-rails (0.3.4)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      haml (~> 3.0)
      railties (~> 3.0)
    hashery (2.0.1)
    heroku (2.31.2)
      heroku-api (~> 0.3.4)
      launchy (>= 0.3.2)
      netrc (~> 0.7.7)
      rest-client (~> 1.6.1)
      rubyzip
    heroku-api (0.3.4)
      excon (~> 0.16.1)
    hike (1.2.1)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.1.2)
      railties (>= 3.1.0, < 5.0)
      thor (~> 0.14)
    json (1.7.5)
    launchy (2.1.2)
      addressable (~> 2.3)
    less (2.2.2)
      commonjs (~> 0.2.6)
    less-rails (2.2.3)
      actionpack (>= 3.1)
      less (~> 2.2.0)
    libwebsocket (0.1.5)
      addressable
    listen (0.5.0)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.19)
    multi_json (1.3.6)
    mysql2 (0.3.11-x86-mingw32)
    netrc (0.7.7)
    nokogiri (1.5.5-x86-mingw32)
    orm_adapter (0.4.0)
    pdf-reader (1.2.0)
      Ascii85 (~> 1.0.0)
      hashery (~> 2.0)
      ruby-rc4
    pg (0.14.1-x86-mingw32)
    polyamorous (0.5.0)
      activerecord (~> 3.0)
    polyglot (0.3.3)
    prawn (0.12.0)
      pdf-reader (>= 0.9.0)
      ttfunk (~> 1.0.2)
    progressbar (0.11.0)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.8)
      actionmailer (= 3.2.8)
      actionpack (= 3.2.8)
      activerecord (= 3.2.8)
      activeresource (= 3.2.8)
      activesupport (= 3.2.8)
      bundler (~> 1.0)
      railties (= 3.2.8)
    rails_best_practices (1.10.1)
      activesupport
      awesome_print
      colored
      erubis
      i18n
      progressbar
      sexp_processor
    railties (3.2.8)
      actionpack (= 3.2.8)
      activesupport (= 3.2.8)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (0.9.2.2)
    ransack (0.7.0)
      actionpack (~> 3.0)
      activerecord (~> 3.0)
      polyamorous (~> 0.5.0)
    rantly (0.3.1)
    rb-fsevent (0.9.1)
    rdoc (3.12)
      json (~> 1.4)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rspec (2.11.0)
      rspec-core (~> 2.11.0)
      rspec-expectations (~> 2.11.0)
      rspec-mocks (~> 2.11.0)
    rspec-core (2.11.1)
    rspec-expectations (2.11.3)
      diff-lcs (~> 1.1.3)
    rspec-instafail (0.2.4)
    rspec-mocks (2.11.2)
    rspec-rails (2.11.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.11.0)
    rspec-steps (0.0.8)
      rspec (>= 2.6)
    ruby-progressbar (0.0.10)
    ruby-rc4 (0.1.5)
    rubyzip (0.9.9)
    sass (3.2.1)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.25.0)
      childprocess (>= 0.2.5)
      libwebsocket (~> 0.1.3)
      multi_json (~> 1.0)
      rubyzip
    sexp_processor (4.0.1)
    simple_form (2.0.2)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    simplecov (0.6.4)
      multi_json (~> 1.0)
      simplecov-html (~> 0.5.3)
    simplecov-html (0.5.3)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.6-x86-mingw32)
    thin (1.4.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.16.0)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    ttfunk (1.0.3)
    twitter-bootstrap-rails (2.1.2)
      actionpack (>= 3.1)
      less-rails (~> 2.2.3)
      railties (>= 3.1)
    tzinfo (0.3.33)
    uglifier (1.3.0)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    warden (1.2.1)
      rack (>= 1.0)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  bootstrap-sass
  cancan
  capybara
  coffee-rails (~> 3.2.1)
  database_cleaner
  debugger
  decent_exposure
  devise!
  eventmachine (= 1.0.0.rc.4)
  execjs
  factory_girl_rails (~> 2.0)
  fuubar
  guard-rspec
  haml-rails
  heroku
  jquery-rails
  launchy
  mysql2
  pg
  prawn
  rails (~> 3.2.3)
  rails_best_practices
  ransack
  rantly
  rb-fsevent
  rspec-instafail
  rspec-rails
  rspec-steps
  sass-rails (~> 3.2.3)
  selenium-webdriver
  simple_form
  simplecov
  sqlite3
  therubyracer
  thin
  twitter-bootstrap-rails
  uglifier (>= 1.0.3)

【问题讨论】:

【参考方案1】:

我强烈建议您遵循 Daniel Kehoe 的优秀: https://github.com/RailsApps/rails3-bootstrap-devise-cancan 如果您还没有的话。

关于我在您的 Gemfile 中看到的唯一可疑之处是其中包含“rubyracer”。为什么会在那里?尝试删除它。当然,无论何时进行任何更改,都不要忘记bundle install

【讨论】:

感谢您的建议。问题是这是我已经构建并成功托管在 heroku 上的现有应用程序。但是现在我正试图让一些朋友在他们的本地 Windows 机器上运行它,我遇到了这个问题。我最初是在 mac 上开发的应用程序,所以我没有这个问题。理想情况下,我希望不必更改应用程序以供他们使用,而是要弄清楚如何安装依赖项。谢谢! gem 'therubyracer', :platforms => :ruby 不会在 Windows 上安装 therubyracer。捆绑包完成得很好。就像我说的那样,它只是“认为”它需要红宝石赛车,而实际上它不需要。 你看过这些帖子吗,它们可能与你的情况有关:***.com/questions/8421321/…***.com/questions/6356450/therubyracer-gem-on-windows和(还有一个)github.com/cowboyd/therubyracer/issues/126 我已经查看了这些,以及 'therubyracer' 上的所有其他线程,并在 windows 上处理这些 gem 依赖项。我还查看了 github 上的未解决问题和 steriobooster 必须在 Windows 上安装“therubyracer”的开放请求请求(截至上周五)但是,我修改了我的依赖项,因此我实际上不需要安装 therubyracer .不只是“认为”它需要安装它(成功的捆绑包,但是当您使用 rails rails 时会爆炸)。所以我的问题是,我如何才能意识到它不需要 therubyracer?? 我已经研究了一段时间,我得出的结论是只使用 commonjs 将我的界面与 less.js 捆绑在一起,并在客户端编译 less。资产管道很好,但没有一个干净的方法可以围绕 ruby​​racer 使用 ruby​​ 进行更少的编译,并且 UI 更好地服务于只需要我在页面上需要的内容。

以上是关于使用 less (2.2.1) 会引发需要 therubyracer 的错误(无法在 Windows 上安装 therubyracer)的主要内容,如果未能解决你的问题,请参考以下文章

less表达式使用

刷新CollectionView 报错the item height must be less that the height of the UICollectionView minus the s(

离线gdb导入sde时,面要素提示the number of points is less than required

对于路径,“getNumberOfTransporters”函数会引发异常

grid安装前检查报PRVE-0426:/dev/shm less than the require

(83)zabbix Less than 25% free in the configuration cache解决