How do I figure out which gem(s) caused a particular gem to be bundled?
Normally Gemfile.lock
documents which dependencies were generated from other dependencies, it's listed in a rough tree form, but you may have to do some digging to get to the right spot.
How do I find out which gem has a specific dependency?
In the bash shell you can do:
gem dependency name_of_the_gem --reverse-dependencies
For instance:
$ gem dependency activesupport --reverse-dependencies
Gem activesupport-2.3.14
Used by
actionpack-2.3.14 (activesupport (= 2.3.14))
activerecord-2.3.14 (activesupport (= 2.3.14))
activeresource-2.3.14 (activesupport (= 2.3.14))
How to find out which gems depdend on gem X
gem-dependent tells you...
Ruby - How to find out all dependencies of a given Gem in a .rb file?
You can yank the code out of lib/rubygems/commands/dependency_command.rb
. Here's a simple method I made.
require 'rubygems/commands/dependency_command'
def get_dependencies name, local = true
cmd = Gem::Commands::DependencyCommand.new
dependency = cmd.gem_dependency name, nil, nil
specs =
if local
dependency.matching_specs.uniq.sort
else
cmd.fetch_remote_specs(dependency).uniq.sort
end
dependencies = []
specs.each do |spec|
dependencies.concat spec.dependencies.sort_by { |dep| dep.name }.map { |dep| [dep.name, dep.requirement] }
end
dependencies
end
puts get_dependencies('diamond_shell', false)
Command for displaying a gem's dependencies?
The following information was pulled from the rubygems command reference linked below.
http://guides.rubygems.org/command-reference/#gem-dependency
The first command you're asking for is "gem dependency". Below is the command description.
gem dependency GEMNAME [options]
Options:
-v, --version VERSION Specify version of gem to uninstall
-r, --[no-]reverse-dependencies Include reverse dependencies in the output
-p, --pipe Pipe Format (name --version ver)
Common Options:
--source URL Use URL as the remote source for gems
-h, --help Get help on this command
--config-file FILE Use this config file instead of default
--backtrace Show stack backtrace on errors
--debug Turn on Ruby debugging
Arguments:
GEMNAME name of gems to show
Summary:
Show the dependencies of an installed gem
Defaults:
--version '> 0' --no-reverse
The second command you'll need is "gem install". Dependencies get installed automatically. Read the quote below from the command reference for more detail.
"gem install" will install the named
gem. It will attempt a local
installation (i.e. a .gem file in the
current directory), and if that fails,
it will attempt to download and
install the most recent version of the
gem you want.If a gem is being installed remotely,
and it depends on other gems that are
not installed, then gem will download
and install those, after you have
confirmed the operation.
Bundler: find which gem depends on this?
You could try looking inside your Gemfile.lock file.
Dependencies are nested underneath what they are required by.
Related Topics
How to Fix an Accidental 'Sudo Bundle Install Dir_Name'
How to Parse a Url and Extract the Required Substring
How to Click on a Specific Coordinates of an Element
Ruby.Metaprogramming. Class_Eval
Convert Hash Keys to Lowercase -- Ruby Beginner
R Statistical Package Gem for a Rails Application
Ruby-Rails Serve Ftp File Direct to Client
How to Do Ruby Object Serialization Using JSON
How the Anchor \Z and \G Works in Ruby
"Encoding::Invalidbytesequenceerror" Error Occurs in Rails 3.1.0
Rmagick - How to Find Out the Pixel Dimension of an Image
Cannot Install Any Version of Ruby on Mojave - Internal Ranlib Command Failed
Does Ruby Have Any Number Formatting Classes
Why Don't More Projects Use Ruby Symbols Instead of Strings
Undefined Local Variable Based on Syntax in Ruby