好的,所以我在构建我的 Docker 镜像时遇到了一个错误(将其视为类似于部署步骤,如果您不熟悉 Docker,则可以将其视为 Heroku 部署)。
当预编译步骤发生时,正在寻找 :test
和 :development
组中的 Gem,因为我已经捆绑了 --without开发测试
- 因为我不想让 QT 只是为了 capybara-webkit
不会在 bundle 上出错 - 预编译步骤会引发错误。
错误总是以下的变体:
Could not find <gem-name> in any of the sources (Bundler::GemNotFound)
我的 gem 文件:
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,并询问了我的同事,但我仍在为此苦苦思索。
最佳答案
bundle install --path vendor/cache
试试这个,如果不起作用请告诉我!
关于ruby-on-rails - Rake Assets 在开发或测试组中没有 Gems 预编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31442342/