Bundler and RubyGems: The Ruby Standard
Understand how libraries are managed in the language that popularized modern package management.
1 Loading...
Bundler and RubyGems: The Ruby Standard
Ruby was one of the first languages to solve the “dependency hell” problem elegantly, inspiring tools like npm, Yarn, and Cargo.
RubyGems
RubyGems is the package format and hosting service. A “Gem” is a package. To install a gem manually:
gem install rails
Bundler
While Gems install packages, Bundler manages project dependencies. It ensures that every machine running your project has the exact same versions of the gems.
Key Files
-
Gemfile: You declare what you need.
source 'https://rubygems.org' gem 'rails', '~> 7.1.0' gem 'pg' -
Gemfile.lock: Bundler freezes the versions here.
Commands
bundle install: Installs dependencies from the Gemfile.bundle exec: Runs a command in the context of the bundle (avoiding version conflicts with system gems).
Conclusion
The combination of RubyGems and Bundler is mature, stable, and simple. It just works, allowing Rubyists to focus on building apps.