Update Local Gem Source Code

Update local gem source code

If you use bundle config local.GEM_NAME /path/to/local/git/repository from the command line then every time you reload your application it will load the latest source from your file system.

To remove the changes (when you have pushed your code to GitHub or RubyGems), you need to run bundle config --delete local.GEM_NAME

Source: http://bundler.io/v1.10/git.html

Rails: Extract and Edit Source Code of Specific Gem

If you find an error in gem, you'd better make pull request on GitHub. But let's suppose you need your private fork of gem. Best workflow for that:

  1. Download the gem source code from GitHub: git clone https://github.com/author/awesome_gem.git.
  2. In your project's Gemfile add gem awesome_gem, path: "/local/path/to/awesome_gem"
  3. Run bundle install

Now you can make changes to the gem locally, and have your project use local copy of it. When you are done making initial changes, push your Gem to your github repository, and change Gemfile line to something like:

gem awesome_gem, github: 'QQQ/awesome_gem' ('QQQ' being your Github's account name)

Edit Ruby Gem locally and execute gem?

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.

How can I specify a local gem in my Gemfile?

I believe you can do this:

gem "foo", path: "/path/to/foo"

Run gem from local source code

From the root directory of your gem, try this to execute lib/MyGem.rb:

ruby -Ilib lib/MyGem.rb

or test your gem interactive:

irb -Ilib
> require 'mygem'
true


Related Topics



Leave a reply



Submit