bundler installs the country_select gem from the wrong source - ruby-on-rails

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.

Related

Rails gem fork issue

I'm applying a patch to my fork of 2.3.15 rails for a workaround for one of the latest security issues.
Previously in my gem file I had -
gem 'rails', '2.3.15'
And everything worked as expected. But for my fork I have
gem 'rails', '2.3.15', :git => 'git#github.com:myrepo/rails.git', :branch => 'CVE-2013-0155-fix'
After doing a bundle install and then running my app with bundle exec ruby script/server as per usual, I'm getting this error -
| ./script/../config/boot.rb:64:in `require': no such file to load -- initializer (LoadError)
I thought that maybe I had just messed something up with my fork but when I point my gemfile to the rails git repo I get the same issue.
gem 'rails', '2.3.15', :git => 'git#github.com:rails/rails.git', :tag => 'v2.3.15'
Can anyone explain to me what's up?
Found an excellent blogpost on the issue here - http://robanderson123.wordpress.com/2013/01/05/applying-backported-security-patches-to-rails-2-3/
The big problem being that rails/2-3-stable doesn't have any gemspecs in the repo. Long story short, did a bundle install with rails set to 2.3.15. Copied the rails gemspecs for activerecord etc out of the specifications directory bundle show rails gives into each of the corresponding directories in my fork of rails. With the exception of the rails gemspec which I copied into the railties directory.
After this gem 'rails', '2.3.15', :git => 'git#github.com:myrepo/rails.git', :branch => 'my-2-3-branch' works as expected.

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!

Installing cancan 2.0 gem in Rails 3.1

I'm having trouble installing the cancan 2.0 gem in Windows XP. I am using Rails 3.1 and in my gemfile y have
gem "cancan", :git => "git://github.com/ryanb/cancan.git", :branch => "2.0"
but it keeps saying
No such file or directory - git clone
"git://github.com/ryanb/cancan.git"
My teammates are not having this problem, but the are working in Unix systems.
It sounds like your git is not working properly. Are you using any other git references in your Gemfile?
I copied and pasted the exact same thing in my gemfile and it worked just fine.
gem 'cancan', github: 'ryanb/cancan', branch: '2.0'

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.

Bundler dependency ~> doesn't recognize beta versions from github properly

Here's a part of my Gemfile:
gem 'rails', "3.1.0"
gem "sprockets", :git => 'git://github.com/sstephenson/sprockets.git', :tag => "v2.0.0.beta.13"
When try to do bundle install, it says that rails 3.1.0 depend on sprockets ~> 2.0.0
Apparantely, this beta version that is downloaded from github is not recognized as a newer version. However, if I put gem "rails", "3.1.0.rc5" in my Gemfile it works fine.
How do I tell bundler to ignore this sprocket dependency or otherwise resolve this issue? And whose issue is that: bundler's or sprockets'?
Have you tried using:
gem 'rails', '~> 3.1'
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git', :tag => 'v2.0.0.beta.13'
It's possible that your pinning rails to 3.1.0 actually forces the use of the 2.0.0 Sprockets gem. That said, I'm not sure that using a soft pin to rails 3.1 is going to ease out the dependency from rails to sprockets and let you use the beta version instead of the "release" one...

Resources