RedBassett RedBassett - 6 months ago 26
Ruby Question

Gem "Malformed Version Number String"

I'm building a gem. I just got the basic project structure laid out, and I tried building it with

gem build my_gem.gemspec
, which worked fine. Then I installed it with
gem install My\ Gem-0.0.1.gem
and it still looked like it worked fine. Then I tried to run
irb
and I got this:

/Users/<username>/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/version.rb:206:in `initialize': Malformed version number string on (ArgumentError)


Then I tried making some changes and saved them. I ran
gem build my_gem.gemspec
. Same error. All
irb
,
rails
, and
gem
sub-commands are generating a stack trace with this at the top. What did I do to break all of these commands and how do I reverse it?

Answer

You should manually delete your gem:

cd $GEM_HOME
find . -path \*my_gem\*

If everything looks good (i.e. there are no files which aren't related to your gem):

find . -path \*my_gem\* -delete

Before installing your gem again, make sure you specified version in your .gemspec.

UPD.

Other locations to look for the residue of the gem:

~/.rvm/gems/ruby-<version>@global
~/.rvm/gems/ruby-<version>
/System/Library/Frameworks/Ruby.framework/
# look for "GEM PATHS" section
gem env
# rbenv paths
~/.rbenv/versions
~/.gem/

UPD2

Problem solved! Steps taken:

This showed where exactly is this particular Rubygems executable, which failed to load:

rbenv which gem
# => /Users/<username>/.rbenv/versions/2.2.2/bin/gem

Then it turns out under 2.2.2 directory there were cache, doc and specifications directories, all of which contained a file or sub-directory with the residue of the broken gem. Deleting them all solved the problem.

Comments