megas megas - 11 months ago 65
Ruby Question

Couldn't install local gem

I'm trying to install a gem that i'm developing from local.

gem install mygem.gemspec

It produces an error:

ERROR: Could not find a valid gem 'mygem.gemspec' (>= 0) in any repository

I can't find any error why it doesn't work, what might be a problem here?

Answer Source

You don’t install the .gemspec file, you use that to build the gem, and then install the resulting gem.

Something like:

$ gem build mygem.gemspec
Successfully built RubyGem
Name: mygem
Version: 1.0.0
File: mygem-1.0.0.gem

and then:

$ gem install mygem-1.0.0.gem
Successfully installed mygem-1.0.0
1 gem installed