Problem with RVM and gem that has an executable

Posted by djhworld on Stack Overflow See other posts from Stack Overflow or by djhworld
Published on 2011-01-12T21:19:43Z Indexed on 2011/01/12 22:53 UTC
Read the original article Hit count: 345

Filed under:
|
|
|

Hi there, I've recently made the plunge to use RVM on Ubuntu.

Everything seems to have gone swimmingly...except for one thing. I'm in the process of developing a gem of mine that has a script placed within its own bin/ directory, all of the gemspec and things were generated by Jeweler.

The bin/mygem file contains the following code: -

#!/usr/bin/env ruby
begin
  require 'mygem'
rescue LoadError
  require 'rubygems'
  require 'mygem'
end
app = MyGem::Application.new
app.run

That was working fine on the system version of Ruby.

Now...recently I've moved to RVM to manage my ruby versions a bit better, except now my gem doesn't appear to be working.

Firstly I do this: -

rvm 1.9.2

Then I do this: -

rvm 1.9.2 gem install mygem

Which installs fine, except...when I try to run the command for mygem

mygem

I just get the following exception: -

daniel@daniel-VirtualBox:~$ mygem 
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- mygem (LoadError)
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p136/gems/mygem-0.1.4/bin/mygem:2:in `<top (required)>'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p136/bin/mygem:19:in `load'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p136/bin/mygem:19:in `<main>'mygem

NOTE: I have a similar RVM setup on MAC OSX and my gem works fine there so I think this might be something to do with Ubuntu?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ubuntu