How to unpack a gem from github and specify the branch? - ruby-on-rails

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!

Related

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"

bundler installs the country_select gem from the wrong source

In my Rail 3.2.13 gemfile I have added the country_select gem
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git'
Rrunning bundle install however loads the wrong version of the gem. It instead loads the out-dated repository at https://github.com/rails/country_select
This happens in my development environment as well as when deploying my app to Heroku.
I was able to overcome this in my dev environment by using the ruby gem specific_install however that doesn't help with heroku.
Any ideas?
You have to update your Gemfile.lock with the git path:
bundle update country_select
It should do the trick.
You can set the branch you want to use on the remote git repository using:
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git', branch: 'master'
or event a commit tag:
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git', revision: 'commit_tag_here'
Beside, when running in Production, a good practice is to fix your gem versions in order to avoid unwanted gem updates.

How to edit a gem at Heroku

I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is a fork that does it ( more details at: https://github.com/crowdint/rails3-jquery-autocomplete/pull/95).
Now I need to deploy to Heroku but it will install the official gem. How can I edit it? Or if it's not possible, how can I import a gem to the application?
Thanks.
you can use the fork by specifying the :git path in your Gemfile declaration
something like
gem "_GEM_NAME_", :git => "git://git/repository.git"
your other option would be to just vendor the gem inside your into a directory like vendor/gems/_gem_name and then you could use the :path option as well
gem "_GEM_NAME_", :path => "vendor/gems/_gem_name"

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.

Run gem directly from git repo with bundler

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.

Resources