Senger CodeLab πŸš€

List of installed gems

September 29, 2026

πŸ“‚ Categories: Ruby
🏷 Tags: Rubygems
List of installed gems

Navigating the Ruby ecosystem often means working with a myriad of “gems” – self-contained packages of Ruby code that extend your application’s functionality. For developers, sysadmins, and anyone maintaining Ruby projects, knowing the complete list of installed gems is crucial. This knowledge empowers you to understand your environment, troubleshoot dependencies, and ensure project stability. Whether you’re debugging a tricky error, preparing for a deployment, or simply auditing your system, having a clear inventory of your gems is the first step towards robust and efficient Ruby development. This guide will walk you through the various methods to inspect your installed gems, helping you master your Ruby environment with confidence.

Understanding RubyGems and Your Development Environment

RubyGems is the standard package manager for Ruby, providing a format for packaging Ruby programs and libraries (gems) and a tool for managing their installation. When you develop in Ruby, you invariably rely on gems for everything from web frameworks like Rails to testing tools and database connectors. Each gem has a specific version, and managing these versions is key to preventing conflicts and ensuring your applications run smoothly. Understanding your environment means knowing not just which gems are present, but also their versions and where they are installed.

The importance of knowing your installed gems cannot be overstated. Imagine working on a project that suddenly breaks after a system update. The first thing you’d check are the dependencies – specifically, the gem versions. An outdated gem or a newly installed one with a conflicting version can easily lead to unexpected behavior. Furthermore, when onboarding new team members or setting up a new server, a clear list of installed gems helps replicate the exact development environment, minimizing “it works on my machine” scenarios. This foundational knowledge is essential for any serious Ruby developer, underpinning effective dependency management and system health.

Many developers don’t realize the breadth of gems installed on their system over time. As you experiment with different projects and tools, your gem library can grow significantly. This can sometimes lead to ‘gem bloat,’ where many unused gems consume disk space and potentially complicate dependency resolution. Regularly reviewing your installed gems can help you keep your Ruby environment clean and efficient. According to RubyGems.org, gems are the standard way to package and distribute Ruby programs and libraries, making their management a core aspect of Ruby development.

The gem list Command: Your Basic Inventory

The most straightforward way to get a list of installed gems on your system is by using the gem list command. When executed in your terminal, this command provides a comprehensive output of all gems that RubyGems knows about in your current environment. It typically lists each gem by name, followed by its installed version(s) in parentheses. This simple command is your first line of defense when you need a quick overview of what’s available globally on your system.

For example, running gem list might show entries like rails (7.0.8, 6.1.7), indicating that you have two versions of the Rails gem installed. This is particularly useful for identifying if you have multiple versions of a single gem, which can sometimes be necessary for different projects, but also a source of potential conflicts if not managed carefully. The output is usually sorted alphabetically, making it easy to scan for specific gems. You can also filter this list by providing a regular expression as an argument, such as gem list '^rails' to only show gems starting with “rails”.

To get a more detailed report, you can use various options with gem list. For instance, gem list --local explicitly ensures you’re seeing only locally installed gems, while gem list --remote queries RubyGems.org for available gems, not necessarily those on your system. For a deep dive into each gem’s specific details, including its summary, homepage, and installed path, the gem list --details option is invaluable. This command is often optimized as a featured snippet because it directly answers “How do I see my installed Ruby gems?” by providing the primary command and its basic usage, offering a quick and clear solution.

Leveraging Bundler for Project-Specific Gem Management

While gem list shows all gems on your system, most modern Ruby applications use Bundler to manage project-specific dependencies. Bundler reads your Gemfile, which defines the gems and their versions required for a particular project, and installs them into a project-specific location or a shared gem path managed by Bundler. To get a list of installed gems relevant to your current project, you should use the bundle list command.

The bundle list command, when run inside a project directory containing a Gemfile, will display all gems that Bundler has installed and activated for that specific project. This is crucial because a project might depend on an older version of a gem, even if a newer version is globally installed via gem list. Bundler ensures dependency resolution and isolates your project’s gems, preventing conflicts between different applications on the same system. This command is indispensable for understanding the exact set of dependencies your application relies upon, as defined in its Gemfile.lock file, which records the precise versions of every gem and its dependencies used during the last successful bundle install.

Here’s how to effectively inspect your project’s gems using Bundler:

  1. Navigate to your project directory: Open your terminal and change into the root directory of your Ruby project (e.g., cd my_rails_app).
  2. Ensure Bundler is installed: If not, install it with gem install bundler.
  3. Run bundle install: This command reads your Gemfile and installs all necessary gems, creating or updating your Gemfile.lock.
  4. Execute bundle list: This will display all gems managed by Bundler for your current project, along with their installed versions. You can also use bundle list --only-group development to see gems only for a specific group.
  5. Inspect the Gemfile.lock: For a more detailed, static view of resolved dependencies, open this file directly. It lists every gem, including transitive dependencies, and their exact versions.

For a deeper dive into the intricacies of project dependency resolution and best practices, consider exploring resources on Ruby dependency management to optimize your development workflow.

Advanced Gem Inspection and Troubleshooting

Beyond simply listing gems, understanding your gem environment deeply is critical for advanced troubleshooting and system optimization. The gem environment command offers a wealth of information about how RubyGems is configured on your system. This includes the installation paths for gems, executable directories, and important RubyGems settings. When gems aren’t found or installations fail, checking these paths is often the first diagnostic step. It helps pinpoint if Ruby is looking in the right places or if there are permission issues preventing installation to a particular directory.

Identifying and managing unused gems is another advanced aspect of maintaining a clean Ruby environment. Over time, as projects Question & Answer :

Is there a Ruby method I can call to get the list of installed gems?

I want to parse the output of gem list.

Is there a different way to do this?

This lists all the gems I have installed.

gem query --local 

http://guides.rubygems.org/command-reference/#gem-list

Listing all installed gems