Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop a Ruby GEM without having to install it first?

Tags:

ruby

gem

I'm developing a GEM that I've forked and I'm trying to modify it slightly for my app.

I'm finding it difficult and time consuming because for every change I make I have to

  1. uninstall
  2. build
  3. re-install
  4. run the app

Is there an easier way of which doesn't require repeating all steps above?

like image 897
Roman Avatar asked Feb 28 '13 01:02

Roman


People also ask

Is gem installed with Ruby?

Ruby comes with RubyGems by default since version 1.9, previous Ruby versions require RubyGems to be installed by hand.


1 Answers

To use it in some app using bundler

If what you mean is for using it in a app to test it / use it, you can just specify a path for your gem or even point to a git repo in the Gemfile http://gembundler.com/gemfile.html

Like

gem "mygem", :path => "~/code/gems/mygem"

To use it as a standalone gem. i.e: like rspec or rake that can run outside of an app.

Just specify the path to your gem binary when running the gem command, like:

$ ~/path_to_my_gem/bin/mygem some args

If you can execute inside your gem directory (i.e: the command does not create files in the current directory, or needs any specific files from the current directory), just do this:

$ ./bin/mygem some args

Note that this last one is just for future reference, I think it's not applicable in the OP context.

like image 90
Ismael Avatar answered Oct 05 '22 11:10

Ismael