How to exclude a gem from bundle install even though it's in Gemfile.lock?

Viewed 774

I am working on setting up a new development environment and I realized that I am facing a minor roadblock. I am using Sidekiq Pro in production, but in development I am wanting to avoid it to prevent spreading the license across other developers.

To do so, in my Gemfile I have the following:

group :production do 
  source "https://gems.contribsys.com/" do
    gem "sidekiq-pro"
  end
end

However, this does exist in my Gemfile.lock file:

    sidekiq-pro (5.2.1)
      connection_pool (>= 2.2.3)
      sidekiq (>= 6.1.0)

So when I'm calling bundle install from within a docker build, how do I prevent bundle install from trying to use the sidekiq-pro gem? The problem is that it errors out because of authentication being required:

Step 6/12 : RUN bundle install --without production
 ---> Running in 0642e1440b33
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Authentication is required for gems.contribsys.com.
Please supply credentials for this source. You can do this by running:
 bundle config gems.contribsys.com username:password
The command '/bin/sh -c bundle install --without production' returned a non-zero code: 17
ERROR: Service 'app' failed to build

As you can see, I have specified --without production in the bundle install arguments, but no luck.

1 Answers

An alternative (though not so elegant) to the --without option is another gem called bundle-only. It uses the CLI and it can bundle install a specific environment. A good thing is that this gem will not occupy space in your Gemfile.lock.

Gem repo here

Run:

  • gem install bundle-only
  • bundle-only production
Related