ruby-on-rails - Rake Assets 在开发或测试组中没有 Gems 预编译

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

好的,所以我在构建我的 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/

相关文章:

ruby-on-rails - ImageMagick - "CORE_RL_magick_.dll not found"或如何使用 ruby​​ 1.9.2 在 Windows 上安装 RMagick

ruby-on-rails - 正则表达式忽略以下划线开头的单词或文件开头的路径

ruby-on-rails - 将字符串映射到 Ruby Rails 中的另一个字符串

ruby-on-rails - 使用 Active Admin 和 Elastic Search 时 Ransack::Search 的未定义方法 `each'?

ruby-on-rails - 无法停止进程,在 tmp/pids/thin.8080.pid (Thin::PidFileNotFound) 中找不到 PID

ruby - for循环的用法?

ruby-on-rails - 尝试在 ruby​​ 中使用正则表达式来查找特定字符

ruby-on-rails-4 - Rails 4.0、sass、Zurb Foundation : Warning. 保存缓存时遇到错误...无法转储匿名类

ruby-on-rails - 访问 select_tag 选定值

sql - 查找所有没有关联记录的记录