Running Local Gems Without a Github Repository?

131 views
Skip to first unread message

Jon

unread,
Apr 13, 2016, 1:50:49 PM4/13/16
to ruby-bundler
Hello,

Up until this moment I used to manually edit my Gemfile with the ':path' parameter when testing gem code locally. I recently moved into Rubymine and sadly when I'm using the ':path' parameterIt won't index this specific gem (which basically mean I can not search files in that gem). I was checking Bundle help file and noticed this command:

bundle config local.GEM_NAME PATH


This is great because It can both solve my issue and I always was bothered changing the Gemfile (as  it's triggered 'modified' on git). However, it seems to only work if your gem is hosted on a Github repository according to the examples? We don't deploy our gem from Github, but from Nexus (Sonatype). Is there any omit the coupling to the :github flag and just use the gem name like so:

gem 'my_gem'

And have bundle pick the local version set by the configuration (bundle config local)?
Thanks.

André Arko

unread,
Apr 14, 2016, 4:48:52 PM4/14/16
to ruby-b...@googlegroups.com
Hi,

It’s only possible to use local gems combined with a git checkout of that gem. Bundler needs to be able to update `Gemfile.lock` so that you will have the same code in production when you push your code and deploy it—the only way to do that is to put the git commit sha into the lock.

--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
To post to this group, send email to ruby-b...@googlegroups.com.
Visit this group at https://groups.google.com/group/ruby-bundler.
For more options, visit https://groups.google.com/d/optout.

Jon

unread,
Apr 18, 2016, 8:55:06 AM4/18/16
to ruby-bundler
Thanks for the reply Andre.
 
It’s only possible to use local gems combined with a git checkout of that gem

But isn't :path doing it differently? I mean - :path does not force you to use a specific sha. Is there any equivalent to bundle config local.GEM_NAME PATH that works like :path works?
If not, it might be an interesting idea to fork bundle and contribute to the project. Just want to make sure it does not exists in that form before.

André Arko

unread,
Apr 18, 2016, 11:46:28 AM4/18/16
to ruby-b...@googlegroups.com
The :path option is for gems that are vendored inside your repository and checked in to your application--you can use it to point to gems anywhere, but that makes it impossible to deploy your application, or even share the same versions with other developers.

The primary reason Bundler exists is to ensure that every checkout of will get the exact same versions of every dependency, but that is impossible if you use :path to point to outside gems that aren't got repos. That's why what you're describing isn't a feature today.

--

Jon

unread,
Apr 26, 2016, 9:52:37 AM4/26/16
to ruby-bundler
Hi Andre,

Thanks again for the answer.
I was sure the :path was a debugging tool to avoid building your gem and installing them.
Actually, the outside gems are indeed sitting in a git repository, but the git repository holds both application code and test code (the test code is the gem). so:

"gem 'GEM_NAME', github: ' my/gem', branch: 'master'"

Will not work because the repository is not a single gem as I mentioned. The gem sits on a specific folder in that repository (for example test/mygem/mygem.gemspec).
Anyway, :path, seems more appropriated for debugging because when working with a git repo I'm forced to commit every change (even a type) for the project to pick the changes don't I?

André Arko

unread,
Apr 26, 2016, 5:30:53 PM4/26/16
to ruby-b...@googlegroups.com
Hi Jon,

You can use any gem out of that git repo that you want. For example, the rails/rails repository contains many gems, and those gems can be used without using the top-level “rails” gem. So that’s not a problem. Furthermore, you don’t have to create a git commit to be able to load your changes locally when using git locals. Have you tried git locals? It sounds like they do exactly what you want.

If you are purely debugging and don’t want to commit or push your changes, I definitely suggest using :path.

Jon

unread,
Apr 27, 2016, 5:42:46 AM4/27/16
to ruby-bundler
Thanks for the answer again Andre.

No I haven't tried git locals because I wasn't aware I can navigate to specific git repository. We use 'Stash' but I think I saw somewhere you can also use bundler with stash, so I'll give it a go! :-)

This actually raise another question. What we currently do is to build our gems into .gem file, and upload this .gem file into Nexus. Then we just add another source in the Gemfile to grab it.
Is there any benefit of using a git repository directly? I'm I understand it right - this eliminated the need to build your gem manually and gem version is not much of an issue because you can pick a gem by a commit or git tag?

André Arko

unread,
Apr 28, 2016, 8:28:30 PM4/28/16
to ruby-b...@googlegroups.com
Git gems exist for times when you need to develop both an app and it’s dependency at the same time. Git repositories come with overhead and potential issues that are absent with regular gems, so anytime that it’s possible to do so, release gems and use them instead.

Jon

unread,
May 1, 2016, 3:53:08 AM5/1/16
to ruby-bundler
I see. Good to know. Thanks for all the help Andre, it was very educational for me :)
Reply all
Reply to author
Forward
0 new messages