Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find licenses of all installed ruby gems?

Tags:

ruby

For legal needs, I need to document all the installed gems and their licences on our instances. The gem list command lists all the gems. Is there a programmatic way to also list the licenses?

like image 999
Vivek Kodira Avatar asked May 06 '17 06:05

Vivek Kodira


People also ask

How do I get a list of installed gems?

Listing Installed Gems The list command shows your locally installed gems: $ gem list *** LOCAL GEMS *** abbrev (default: 0.1. 0) awesome_print (1.9. 2) base64 (default: 0.1.

Which is the command used to list all the gems available in Ruby?

The list command is used to view the gems you have installed locally.

How do you check if I have a gem installed?

To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.

Where are my gems installed?

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1. 0/bin You may want to add this to your PATH.


2 Answers

From the Rails console:

For some Gems, which have its license information included inside its spec, you can display them running this from the rails console:

Gem.loaded_specs.each do |name, spec|
  puts "#{name}: #{spec.license}"
end

or From your linux bash terminal:

for i in `gem list | cut -d" " -f1`; do echo "$i :" ; gem spec $i license; done
like image 147
Hugo Avatar answered Sep 21 '22 21:09

Hugo


You can often find licensing information either on rubygems.org (derived from the gemspec data) or on the developer's source code repository.

Good Luck!

like image 23
Myst Avatar answered Sep 21 '22 21:09

Myst