pguardiario
pguardiario

Reputation: 54984

load a gem's gemspec

I'm trying to load a gem's gemspec from inside my ruby script. I expected to be able to do:

`gem spec rake`
# ERROR:  No gem matching 'rake (>= 0)' found

I also tried:

Gem::Specification.find_by_name('rake')
# Gem::LoadError: Could not find 'rake' (>= 0) among 21 total gem(s)

When I do gem spec rake from the console I get the correct output.

Upvotes: 1

Views: 484

Answers (1)

SreekanthGS
SreekanthGS

Reputation: 988

Gemfile:

source 'https://rubygems.org'
gem 'rake'

test.rb:

require 'rake'
p Gem::Specification.find_by_name('rake')

Executed:

bundle install
bundle exec ruby test.rb

Output:

#<Gem::Specification:0x12c1b1c rake-10.3.1>

Upvotes: 1

Related Questions