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))
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.
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 to see the dependency tree just from Gemfile?
gem dependency
(with no args) should show you all gems from current system with their dependencies.
bundle exec gem dependency
will show you for the current Gemfile
Edit:
You can also do gem dependency -R
(or just dep
instead of dependency
) if you want to find out which gems use specific (or all) gems.
For deeper dependencies I'd parse output (regex maybe?) of first gem dependencies, pick gem's names and call gem dep
on each of them, but that's just a loose idea.
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.
Rails 5: How Do I Find Out Which Gem Depends on a Specific Ruby Version?
Your case seems like not a gem dependencies, but like you have ruby version definition somewhere in your apps code.
Check this files under your projects root folders:
- .rvmrc
- .ruby-version
- .ruby-gemset
- .versions.conf
And also check your Gemfiles for string ruby-2.5.2
.
Get all dependencies of a specific version of a Gem on RubyGems
I found the solution. The best (and only way) is to use the dependency file of a gem, who list all dependencies of each version of the gem.
To get this file, it's necessary to call the dependency address of the API : http://guides.rubygems.org/rubygems-org-api/#misc-methods (the last one).
After that, this few line do all the stuff to get dependencies of a specific version :
url = URI("https://rubygems.org/api/v1/dependencies?gems=#{gem_name}")
dependencies = Net::HTTP.get(url)
data = Marshal.load(dependencies).each do |dependency|
break dependency if dependency[:number] == gem_version
end
Related Topics
Passing Multiple Error Classes to Ruby's Rescue Clause in a Dry Fashion
Forking a Gem for a Rails Project
How to Check for File Existence
Parsing Xls and Xlsx (Ms Excel) Files with Ruby
How (Replace|Create) an Enum Field on Rails 2.0 Migrations
Macos Mojave 'Ruby/Config.H' File Not Found
Rails - the System Cannot Find the Path Specified
Ruby Regexp Group Matching, Assign Variables on 1 Line
Rails: Should Partials Be Aware of Instance Variables
Devise Logged in Root Route Rails 3
How to Find Out Which Gem Has a Specific Dependency
Understanding Ruby .Class and .Ancestors Methods
Ruby Craziness: Class VS Object
How to Install Ruby 2 on Ubuntu Without Rvm
Finding Out Current Index in Each Loop (Ruby)