我正在尝试在我的第一个 Rails 项目上使用 twitter-bootstrap-rails gem,在运行的 Windows 7 机器上

ruby 1.9.3p125 (2012-02-16) [i386-mingw32] 
Rails 3.2.1 
twitter-bootstrap-rails 2.1.1 

当我跑 rails g bootstrap:install我得到以下信息:
[WARNING] Please install gem 'therubyracer' to use Less. 
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.5/lib/bundler/runtime.rb:74:in `require': cannot load such file -- twitter/bootstrap/rails (LoadError) 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.1.5/lib/bundler/runtime.rb:74:in 'rescue in block in require' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.1.5/lib/bundler/runtime.rb:62:in 'block in require' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.1.5/lib/bundler/runtime.rb:55:in 'each' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.1.5/lib/bundler/runtime.rb:55:in 'require' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-.1.5/lib/bundler.rb:119:in `require' 
        from H:/Dev/sugarcane/config/application.rb:7:in `<top (required)>' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:24:in `require' 
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:24:in `<top (required)>' 
        from script/rails:6:in `require' 
        from script/rails:6:in `<main>' 

这是我的 Gemfile:
source 'https://rubygems.org' 
gem 'rails', '3.2.1' 
gem 'pg' 
 
group :assets do 
  gem 'sass-rails',   '~> 3.2.3' 
  gem 'coffee-rails', '~> 3.2.1' 
  gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' 
  gem 'uglifier', '>= 1.0.3' 
end 
 
gem 'jquery-rails' 

我试过包括 gem therubyracer在我的 Gemfile 中,但我收到有关 libv8 gem 的编译错误,其中 isn't available on Windows .我也试过 gem therubyracer, :platform => :ruby ,但 Bundler 仍然尝试在 bundle install 上安装 therubyracer .我还尝试安装 node.js 并包括 gem execjs ,但无济于事。

我遇到的每个解决方案似乎都没有帮助。我想在这个项目中使用 LESS 而不是静态 CSS,因此允许我在 Windows 机器上使用 LESS 和 Rails 的解决方案将是最有帮助的。

请您参考如下方法:

我已经改用 bootstrap-sass gem 。

因此,我可以使用 SASS 作为 CSS 预处理器,而不是使用 LESS。缺点是它似乎没有任何代码生成器。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!