Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit Ruby Gem locally and execute gem?

Tags:

ruby

rubygems

For a project I'm working on, I have to do some work on an existing Ruby Gem. I haven't got much previous experience with Ruby and am struggling with a few aspects.

I have the repository cloned locally. I need to edit the current files in the /lib/ directory, which I can do. Is it possible for me to compile the edited files into a Gem and run this Gem? Any help would be really appreciated.

like image 377
Kanery Avatar asked Oct 23 '25 18:10

Kanery


1 Answers

Yes! You can include the gem in a local project and point the Gemfile to your local directory:

Gemfile

source 'https://rubygems.org'

gem 'my_local_gem', path: '/absolute/path/to/your/gem'

Then edit the gem, run your local program and see the changes.

Additionally, you don't always have to clone a whole gem, you can install it via rubygems and use bundle open <gem_name> to open the gem's contents in your supplied editor.

I have written a post describing just that and more here.

like image 189
yez Avatar answered Oct 26 '25 10:10

yez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!