Could not load "gem" add gem to development group of your gemfile

When running bundle install, I am getting the following error:

/usr/local/bundle/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile (LoadError)

This morning I have been trying to reorganize my Gemfile so that my Sidekiq docker container doesn't load all of the gems that are required by the Rails App container (to minimize issues with memory in the Sidekiq container).

As a result, I've taken my Gemfile and have tried to break them out into groups. Here's what it looks like:

source ""
git_source(:github) { |repo| "{repo}.git" }

ruby "2.5.8"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem "rails", "~> 5.2.3"

# Ruby's PostgreSQL connection ability
gem "pg"

# Ability to debug code in real time.
gem "pry"

# Used for mass imports.
gem "activerecord-import", git: ""

gem "sidekiq", github: "mperham/sidekiq"
# Sidekiq used for backgrounding tasks.
# group :production do 
  source "" do
    gem "sidekiq-pro"
# end
gem "sidekiq-scheduler"

# Slack-ruby-client
gem "eventmachine"
gem "async-websocket", "~> 0.8.0"
gem "slack-ruby-client"
gem "websocket-driver"

# SMS Message implementation
gem "twilio-ruby"

gem "aws-sdk-ec2"
gem "aws-sdk-ssm"
gem "aws-sdk-s3"
gem "aws-sdk-rails"
gem "aws-sdk-wafv2"
# gem "aws-sdk-sqs"

# For Stripe
gem "stripe"

# XML/HTML Parser
gem "nokogiri"

# Better Rails C Colors
gem "awesome_print"

group :test, :development, :production do
  # Use Puma as the app server
  gem "puma", "~> 3.11"
  # Use SCSS for stylesheets
  gem "sass-rails", "~> 5.0"
  # Use Uglifier as compressor for JavaScript assets
  gem "uglifier", ">= 1.3.0"
  # See for more supported runtimes
  gem "mini_racer", platforms: :ruby

  # Use CoffeeScript for .coffee assets and views
  gem "coffee-rails", "~> 4.2"
  # Turbolinks makes navigating your web application faster. Read more:
  gem "turbolinks", "~> 5"
  # Build JSON APIs with ease. Read more:
  gem "jbuilder", "~> 2.5"

  # Reduces boot times through caching; required in config/boot.rb
  gem "bootsnap", ">= 1.1.0" # , require: false

  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
  gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

  # Bootstrap
  gem "bootstrap"

  # jQuery
  gem "jquery-rails"

  # toastr
  gem "toastr_rails"

  # Used for server-side processing of datatables.
  gem "ajax-datatables-rails", "~> 1.2.0"
  gem "jquery-datatables-rails"

  # CSV parsing.
  gem "csv"

  # user authentication
  gem "devise"

  # for document validation
  gem "activestorage-validator"

  # Generates a visual diagram to represent model relationships.
  gem "railroady"

  # for date range picker
  gem "bootstrap-daterangepicker-rails"
  gem "momentjs-rails"

  # tag input
  gem "bootstrap-tagsinput-rails"

  # pagination
  gem "will_paginate"

  # nested associations
  gem "cocoon"

  # Convert number to words.
  gem "humanize"

  # For detecting mime types
  gem "mime"

  # to call the api from rails application
  gem "rest-client"

  gem "activerecord-session_store"

  # To get the next available day after a provided day
  gem "chronic"

  # To get current season for password attacks
  gem "ruby-seasons"

  # active storage validation
  gem "active_storage_validations"

  # Helps identifies the time between two times.
  gem "time_difference"

  # Auto format phone numbers
  gem "jquery_mask_rails"

  # Google Calendar API
  gem "google-api-client", "~> 0.34"

  # Dumping database
  gem "seed_dump"

  gem "jquery-minicolors-rails"

  # Ability to duplicate records
  gem "amoeba"

  # Calculating percentage changes
  gem "percentage"

  gem "jwt"
  gem "intl-tel-input-rails"

  # Establish Audit Trail
  gem "audited", "~> 4.9"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem "byebug", platforms: %i[mri mingw x64_mingw]
  gem "rb-readline"

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem "listen", ">= 3.0.5", "< 3.2"
  gem "web-console", ">= 3.3.0"
  # letter opener
  gem "letter_opener"
  # Spring speeds up development by keeping your application running in the background. Read more:
  gem "bullet"
  gem "spring"
  gem "spring-watcher-listen", "~> 2.0.0"

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem "capybara", ">= 2.15"
  gem "selenium-webdriver"
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem "chromedriver-helper"

When running bundle install, everything seems to work just fine. No issues; however, I still get this error when running rails c to try to load a rails console. The listen gem is in the development group and always has been, so I'm not sure why this error is occurring.

My goal was to be able to pass bundle install --without production to the Sidekiq Dockerfile when building so that I could only install the gems required for sidekiq, excluding those gems that are in the production group. Can't even run bundle install on its own anymore to "fix" this.

Any help would be greatly appreciated.

Read more here:

Content Attribution

This content was originally published by LewlSauce at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: