7

Okay, so I've got an error while building my Docker image (think of it as similar to a deploy step, or Heroku deploy if you're unfamiliar with Docker).

Gems that are in the :test and :development groups are being looked for when the precompile step happens, and since I've bundled --without development test - as I don't want to have QT just so that capybara-webkit doesn't error on bundle - the precompile step is throwing an error.

The error is always a variant of:

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

My 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

The line in the Dockerfile where the error happens is:

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

So basically, what I'm really after is the equivalent for --without test development for the rake task. Can I do that? As per some advice, I've already changed (in application.rb):

Bundler.require(*Rails.groups)

to

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

Anybody have Rails-fu enough to solve this one? I've looked in the docs and on SO, as well as asking my colleagues but I'm still banging my head against the wall over this.

Alex Lynham
  • 1,318
  • 2
  • 11
  • 29
  • 1
    Did you ever figure this out, because I'm getting that gem not found in any sources error, too, about a dependency (raindrops) of a gem (unicorn) that *is* being installed during the docker build process – Joe Sak Feb 29 '16 at 20:17
  • Exactly which gems are not being found? Most likely what is happening is that one of the gems in your `:development, :test` group is pulling in a dependency that is also used by the asset pipeline. You need to isolate that dependency and put it in your Gemfile outside of the `:development, :test` group. – Chris Mar 07 '16 at 20:46

1 Answers1

1
bundle install --path vendor/cache

Try this and let me know if it doesn't work!

Abhilash Reddy
  • 1,499
  • 1
  • 12
  • 24
  • Thanks, but I ended up ditching `capybara-webkit` to resolve it in the end. Hopefully it will help somebody else! – Alex Lynham Jun 03 '16 at 13:34