Installing cancan 2.0 gem in Rails 3.1 - ruby-on-rails

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'

Related

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.

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.

alternative for github : <repo-name> in gem file

I am trying to build the docrails in my system. When I clone the repo and do bundle install as the guides say.
I get the following error
You passed :github as an option for gem 'rails/active_record_deprecated_finders'
, but it is invalid.
Entry in gemfile looks like this:
gem 'rails/active_record_deprecated_finders', github: 'rails/active_record_deprecated_finders'
To avoid that what I am doing is commenting the rest of the line like this:
gem 'rails/active_record_deprecated_finders'#, github: 'rails/active_record_deprecated_finders'
Then it foregoes that and the next problem arrives with the error message saying:
Could not find gem 'active_record_deprecated_finders (>= 0) x86-mingw32' in any
of the gem sources listed in your Gemfile.
Environment specs:
Bundler version 1.0.21
Rails 3.2.3
Win7 64bit
Question
I dont know why its looking for x86 when my System is 64bit.Is there any work around for this? or its a bug?
If gem file couldn't accept github: as parameter why is it there in the first place?
Please let me know if there are any workarounds to this problem
The :github option is just shorthand for a longer :git option:
gem :foo, :github => 'rails/foo'
Is just short for
gem :foo, :git => 'git://github.com/rails/foo.git'
This is new in bundler 1.1 which is why it doesn't work on your setup. You could rewrite the gemfile but it would probably be easier to update bundler. In addition bundler 1.1 is a lot faster than 1.0

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...

'Could not find gem' error when specifying a forked version of a gem from Github in my gemfile

I am trying to use this forked version of the searchlogic gem. In my gemfile, I have
gem "searchlogic", :git => "http://github.com/railsdog/searchlogic.git"
when I do bundle install, I get this error:
Could not find gem 'searchlogic (>= 0, runtime)' in http://github.com/railsdog/searchlogic.git (at master).
Source does not contain any versions of 'searchlogic (>= 0, runtime)'
What is causing this error? Thanks for reading.
It's because your fork not define searchlogic gem by rd_searchlogic gem. So use in your Gemfile :
gem "rd_searchlogic",
:git => "rd_searchlogic.gemspec",
:require => "searchlogic"
Use:
gem 'rd_searchlogic', :git => 'https://github.com/railsdog/searchlogic.git', :require => 'searchlogic'
The .gemspec of your fork might contain a different name to that of the gem on RubyGems, for example when I forked active_merchant on GitHub their .gemspec file had:
s.name = 'activemerchant'
but the gem is defined as active_merchant on RubyGems so I changed my Gemfile from:
gem "active_merchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
to:
gem "activemerchant", git: "https://github.com/adamwaite/active_merchant.git", require: "active_merchant"
note the lack of _.
All worked perfectly after that. This may be an obscure case, but hope it helps someone!
It doesn't look like that gem has been upgraded for Rails3. From the issues listed in Github, it seems that searchlogic is heavily dependent on ActiveRecord2 and may not be easily upgraded for Rails 3. It may be worth looking into an alternative.
Will searchlogic work with Rails 3?
http://github.com/binarylogic/searchlogic/issues/issue/65

Resources