spot_imgspot_img

Ruby Dependency Management with Bundler

Managing dependencies is a difficult task in any system. Bundler makes it almost enjoyable for Ruby!

Bundler is a dependency manager for Ruby. Projects that are cognizant of dependency management are more favorable than those that rely on manual management. Bundler creates project (or folder) specific bundles of gems with specific versions for that project’s needs. Luckily for us, it is easy to use.

You may want to understand Ruby Version Manager before proceeding.

Installing Bundler

You will need to have a managed version of ruby on your machine before installing.

Verify you have Rubygems installed. Follow the installation instructions if it is not installed.

$ gem -v
2.0.14

Install bundler using rubygems.

$ gem install bundler
Fetching source index from https://rubygems.org/
Installing rake 10.3.0
...
Using bundler 1.6.2
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

Verify that bundler is installed.

$ bundle -v
Bundler version 1.6.2

Using Bundler

Bundler acts as a wrapper when Ruby commands are executed that includes the correct gem versions. Bundle has a few commands you should understand. These are typically executed from a projects directory. A typical use case would be to clone a repository with a Gemfile in its root directory, followed by executing these commands from that directory.

Generate the bundle by downloading the appropriate gems. This command is initiated from any directory that contains a Gemfile. Read the Docs

$ bundle install

Bundler works with Gemfile.lock file that stores the dependency graph for the project. If this file is committed to a project, it locks each gem in the dependency graph to that version. If it does not exist when bundle install is run, the latest versions are installed.

Ruby commands are instructed to use a bundle with the exec command. The following example tells foo to execute with the correct bundle. Read the Docs

$ bundle exec foo

Updating the bundle is straight forward. The bundle update command tells bundler to ignore the contents of the Gemfile.lock and get the latest versions. Read the Docs

$ bundle update

Get in Touch

spot_imgspot_img
spot_img

Get in Touch

[td_block_social_counter facebook="tagdiv" style="style6 td-social-boxed" open_in_new_window="y" f_counters_font_family="394" f_network_font_family="891" f_counters_font_size="eyJhbGwiOiIxNCIsImxhbmRzY2FwZSI6IjEzIiwicG9ydHJhaXQiOiIxMiJ9" f_network_font_size="eyJhbGwiOiIxMyIsImxhbmRzY2FwZSI6IjExIiwicG9ydHJhaXQiOiI5In0=" counter_color="#ffffff" counter_color_h="#ffffff" network_color="#ffffff" network_color_h="#ffffff" tdc_css="eyJsYW5kc2NhcGUiOnsibWFyZ2luLWJvdHRvbSI6IjMwIiwiZGlzcGxheSI6IiJ9LCJsYW5kc2NhcGVfbWF4X3dpZHRoIjoxMTQwLCJsYW5kc2NhcGVfbWluX3dpZHRoIjoxMDE5LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMjAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3NjgsInBob25lIjp7Im1hcmdpbi1ib3R0b20iOiI0MCIsImRpc3BsYXkiOiIifSwicGhvbmVfbWF4X3dpZHRoIjo3NjcsImFsbCI6eyJtYXJnaW4tYm90dG9tIjoiNDAiLCJkaXNwbGF5IjoiIn19" twitter="tagdivofficial" youtube="tagdiv"]

Latest Posts