Run gem directly from git repo with bundler - ruby-on-rails

I am developing a gem to use in my rails app.
The gem is located at /home/me/my_gem.
If I use gem 'my_gem', :git => '/home/me/my_gem' bundler takes it and installs it into ~/.bundler/... but I want the gem to be used directly from /home/me/my_gem so I don't have to run bundle install every time I do a change to the gem.

You need use the :path options
gem 'my_gem', :path => '/home/me/my_gem'
After that you even not need run a bundle install. Each time is your directory code used.

Related

Installing Local Gem Rails 4.2

All right so I have a gem file the is local. In my rails application the gem spec file and the created gem along with all files bundled is located at:
vendor/gems/mygem
In my Gemfile I have
gem 'mygem-1.0', :path => 'vendor/gems/mygem'
When I run:
bundle install
I get an error:
Could not find gem 'mygem-1.0 x86-mingw32' in source at 'vendor/gems/mygem' in source at 'vendor/gems/mygem/'.
Source does not contain any version of 'mygem-1.0 x86-mingw32'
Ok so after taking a break for a few minutes. I noticed that I was actually calling the version number of the gem as part of the gem name:
# What I originally Had
gem 'mygem-1.0', :path 'vendor/gems/mygem'
# What it should be
gem 'mygem', :path 'vendor/gems/mygem'
the bundler added the version number to the gem automatically and I assumed this was part of the file name and the version was specified inside the gemfile itself.

Install gem manually

I want to install a gem mannually.
I have downloaded the content of the git repo, modified the gemfile.lock (delete rails version depedencie in order to use the gem in my superior version of Rails).
But where do I put the folder and how do I add this folder to my gem list?
GitHub repo
In your Gemfile you just put
gem 'gem_name', :path => "path_to_gem"

How to unpack a gem from github and specify the branch?

in my gemfile I use a gem that points to git and a specific branch. How can I unpack a gem in my vendors/gem folder and specify the branch like so?
gem 'devise-async', :git => 'git://github.com/mhfs/devise-async.git', :branch => 'master'
Thanks
After you executed bundle install in your Rails app, you could try the bundle open devise-async to open the gem in your editor and then just save it away?
There's also bundle cache which caches all the used gems of your app in vendor/cache, but I don't know exactly in which kind...
Hope this helps!

Can't install the "refinerycms-memberships" gem

What can i do if i know there is a github repository for the gem but in the terminal i couldn't install the gem via 'gem install' or 'bundle install' because it fails with the following error:
Could not find gem 'refinerycms-memberships (= 1.0)' in any of the gem sources listed in your Gemfile.
I couldn't find it on rubygems.org either, so is there any other way of getting it installed :(
If you're using bundle install then I assume you're installing using a Gemfile. In this case, you can specify a git repo:
gem refinerycms-memberships, :git => "git://path.to/git/repo"
Specifically for this gem, I found this line in my Gemfile to work for me:
gem 'refinerycms-memberships', '~> 2.0.0', :git => 'https://github.com/rbriank/refinerycms_membership.git'
Depending when you see this post, you might need to modify the version or possible add the
:branch => .... option.

How can I vendorize Rails 3?

I have a git submodule of git://github.com/rails/rails in vendor/rails of my Rails 3 app. This is where an unpacked/vendorized Rails would go prior to 3.0.
How do I instruct my Gemfile that vendor/rails is the correct location, and not my system-wide rails install?
So, some people have noted that you can do simply:
gem 'rails', :path => "vendor/rails"
You can also include a version number, e.g.,
gem 'rails', '3.0.3', :path => "vendor/rails"
Both of these depend on what you actually have in vendor/rails. For example, if I do git checkout v3.0.3 in vendor/rails, both of these will work fine on their own (3.0.3 is the current).
But if I use a beta instead, I seem to need to add some additional dependencies:
gem 'rails', :path => "vendor/rails"
gem 'arel', :git => 'git://github.com/rails/arel.git'
gem 'rack', :git => 'git://github.com/rack/rack.git'
I could also extract these into vendor as git submodules, I suppose, and again use :path.
Do be aware that rack comes from rack/rack on github, not rails/rack. The latter is a fork and hasn't been updated since 2009. I made this mistake and spent hours fixing it.
If you've got older versions of rails installed on your machine, you may also need to take care to use script/rails instead of the rails command.
Isn't it just gem 'rails', '3.0.3', :path => "vendor/rails" in your Gemfile?
Use this line in your Gemfile:
gem 'rails', :path => "vendor/rails"

Resources