stk1234
stk1234

Reputation: 1116

Installing a Ruby Gem on a Dockerized Application

I want to install awesome_print in my dockerized ruby application. Running

docker-compose run application_name gem install awesome_print 

says "Successfully installed awesome_print-1.8.0," however, it does not appear in my Gemfile even after running

docker-compose run application_name bundle install

How can I install awesome_print in my dockerized application?

Upvotes: 1

Views: 1554

Answers (1)

max
max

Reputation: 101811

The RubyGems gem command is actually a much older package manager that predates bundler.

Running gem install foo just installs the gem to your local repository (a folder somewhere). It does not add the gem to your Gemfile and it does not perform the dependency tree resolution that Bundler does to ensure that your gems are actually compatible.

Bundler is built on top of gem. To install gems with bundler (which is what you pretty much always want to do) you add the gem to your Gemfile and run bundle install.

gem 'awesome_print', '~> 1.8'

Bundler also has a bundle add command which will add a gem to the Gemfile and install your bundle, for example:

bundle add awesome_print --version "~> 1.8"

Upvotes: 2

Related Questions