Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update local gem source code

I'm testing a gem in a Rails project.

The current Gemfile:

gem 'mygemname', path: '/path/to/my/gem'

When I edit a gem locally I can build the gem, remove the gem from Gemfile, run bundle install, add the gem back to the Gemfile and run bundle install again. Is there an easier way to do this locally?

like image 618
Sarun Intaralawan Avatar asked Jul 15 '15 10:07

Sarun Intaralawan


People also ask

How do I edit a gem?

Download its source code into a separate folder (perhaps from github). Then modify your Gemfile to point to the source directly so that you can edit it and test your changes directly. Then, just modify the source files inside the source tree and you should be able to see your changes applied directly.

What does gem update do?

gem update will update all installed gems to their latest versions, so it will update Rails to 3.0. 0. in your application folder. Thus your application will be associated and run in rails 2.3.

How do I resolve gem dependencies?

Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.


2 Answers

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

like image 55
tpbowden Avatar answered Sep 22 '22 17:09

tpbowden


You can bump your Gem's version. Next time you run bundle your gem will be updated to the next iteration.

VERSION = "1.0.0"

Bump the patch version to

VERSION = "1.0.1"

Now just run bundle. Bundler will notice it and log 1.0.1 (was 1.0.0) in the output.

like image 32
ClikeX Avatar answered Sep 22 '22 17:09

ClikeX