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:
- Download the gem source code from GitHub:
git clone https://github.com/author/awesome_gem.git
. - In your project's Gemfile add
gem awesome_gem, path: "/local/path/to/awesome_gem"
- 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
Load Works on Local Path, Require Doesn'T
Factory_Girl + Rspec Doesn't Seem to Roll Back Changes After Each Example
Undefined Method 'Devise' When Including User Model Outside Rails
What Are Some Examples of Using Nokogiri
I Can't Remove Whitespaces from a String Parsed by Nokogiri
Invoking Knife in a Ruby Class
Failure to Install Old MySQL2 Gem
How to Run Two Methods in Parallel Ruby
What's the Efficient Way to Multiply Two Arrays and Get Sum of Multiplied Values in Ruby
Append Row to CSV File Ruby 1.9 CSV Lib
Heroku: Pg::Connectionbad: Could Not Connect to Server: Connection Refused
Stub Method Only on The First Call with Rspec
Breaking a Large Rails App into Smaller Apps
Converting External CSS to Inline CSS for Mail in Rails
Is There an Easy-To-Use Ftp Library for Ruby
Single Custom Param Name in Routes for Nested Resources Rails 4.1