Rake Assets在开发或测试组中不使用Gems进行预编译

时间:2015-07-15 22:29:10

标签: ruby-on-rails ruby ruby-on-rails-4 gem rake

好的,所以我在构建Docker镜像时遇到了错误(想象它类似于部署步骤,或者如果你不熟悉Docker则会进行Heroku部署)。

预编译步骤发生时,:test:development组中的宝石正在寻找,因为我已经捆绑了--without development test - 因为我不想拥有QT只是为了capybara-webkit不会在bundle上出错 - 预编译步骤会抛出错误。

错误始终是以下的变体:

Could not find <gem-name> in any of the sources (Bundler::GemNotFound)

我的Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.9'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'
gem 'unicorn', '~> 4.8.3'
gem 'unicorn-worker-killer', '~> 0.4.2'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'rdf', '~> 1.1.0'
gem 'tripod', '~> 0.11.1'

gem 'devise'
gem 'devise_invitable'
gem 'authority'
gem 'mongoid', '~> 4.0.0'

gem 'bootstrap-sass', '~> 3.3.3'

# pagination
gem 'kaminari', '~> 0.16.3'
gem 'bootstrap-kaminari-views'

# background processing
gem 'sidekiq'
gem 'sidekiq-status'
gem 'request_store', '~> 1.1.0'

# add memoization
gem 'memoist', '~> 0.12.0'

# dropbox gem for uploads etc
gem 'dropbox-sdk', '~> 1.6.4'

# error reporting
gem 'sentry-raven'

group :development, :test do
  gem "rspec-rails", "~> 3.0.0"
  gem "factory_girl_rails", "~> 4.5.0"
  gem "capybara", "~> 2.4"
  gem "database_cleaner"
  # gem "selenium-webdriver"
  gem 'poltergeist'
  gem 'capybara-webkit'

  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  #gem 'byebug'
  gem 'pry-byebug'
  gem 'better_errors', '~> 2.1.1'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  # gem 'spring'
end

发生错误的Dockerfile中的行是:

RUN /bin/bash -l -c "RAILS_ENV=production bundle exec rake assets:precompile RAILS_GROUPS=assets --trace"

所以基本上,我真正追求的是rake任务的等效--without test development。我能这样做吗?根据一些建议,我已经改变了(在application.rb中):

Bundler.require(*Rails.groups)

Bundler.require(:default, :assets, Rails.env)

任何人都有Rails-fu足以解决这个问题?我查看了文档和SO,以及询问我的同事,但我仍然在撞墙挡住我的头。

1 个答案:

答案 0 :(得分:1)

bundle install --path vendor/cache

试试这个,让我知道它是否有效!