Published using Google Docs
capistrano bundle install issue
Updated automatically every 5 minutes

If you get this error while deploying using Capistrano:

...

  * executing "bundle install --gemfile /home/rubywebw/beytelmouneh.com/releases/20110427162418/Gemfile --path /home/rubywebw/beytelmouneh.com/shared/bundle --deployment --quiet --without development test"

        servers: ["beytelmouneh.com"]

        [beytelmouneh.com] executing command

 ** [out :: beytelmouneh.com] git://github.com/jnicklas/capybara.git (at master) is not checked out. Please run `bundle install`

        command finished in 1060ms

*** [deploy:update_code] rolling back

  * executing "rm -rf /home/rubywebw/beytelmouneh.com/releases/20110427162418; true"

        servers: ["beytelmouneh.com"]

        [beytelmouneh.com] executing command

        command finished in 395ms

failed: "sh -c 'bundle install --gemfile /home/rubywebw/beytelmouneh.com/releases/20110427162418/Gemfile --path /home/rubywebw/beytelmouneh.com/shared/bundle --deployment --quiet --without development test'" on beytelmouneh.com

...

this problem is caused by having the following line in my Gemfile:

  gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git'

To resolve this problem with (either capistrano or bundler ) we have to get a cached local copy of the gem in question, and use the :path key instead of the :git key in the Gemfile. Here we go.

1- Replace above line with:

          gem 'capybara', :path => 'vendor/cache/git/capybara'

2-create the directories

        mkdir vendor/cache

        mkdir vendor/cache/git

3-add it as a submodule.

        git submodule add git://github.com/jnicklas/capybara.git vendor/cache/git/capybara

4-run ‘bundle install’ or ‘bundle’

hani@hanis-lucid:~/rails-proj/bem(master) $ bundle

...

Using mail (2.2.17)

Using actionmailer (3.0.3)

Using capistrano (2.5.21)

Using capistrano-ext (1.2.1)

Using nokogiri (1.4.4)

Using selenium-webdriver (0.2.0)

Using xpath (0.1.4)

Using capybara (1.0.0.beta1) from source at vendor/cache/git/capybara

Using configuration (1.2.0)

Using crack (0.1.8)

Using cucumber (0.10.2)

Using cucumber-rails (0.4.1)

Using database_cleaner (0.6.7)

Using factory_girl (1.3.3)

Using thor (0.14.6)

Using rails (3.0.3)

Using rspec-core (2.5.1)

...

Updating .gem files in vendor/cache

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Voila...

If you are sharing the project on 2 or more machines, and when you checkout the project on the other machine, and try to do ‘bundle’ or ‘rake’, you will get this error:

Could not find gem 'capybara (>= 0, runtime)' in source at vendor/cache/git/capybara.

Source does not contain any versions of 'capybara (>= 0, runtime)'

Try running `bundle install`.

so you try running ‘bundle’ or ‘bundle install’, and you get:

hani@hanis-lucid:~/rails-proj/bem(master) $ bundle

Fetching source index for http://rubygems.org/

Could not find gem 'capybara (>= 0, runtime)' in source at vendor/cache/git/capybara.

Source does not contain any versions of 'capybara (>= 0, runtime)'                                                                                                                                                                                                                 

So to fix this, you need to update the git submodule, here is how to do it.

hani@hanis-lucid:~/rails-proj/bem(master) $ cat .gitmodules

[submodule "vendor/cache/git/capybara"]

            path = vendor/cache/git/capybara

            url = git://github.com/jnicklas/capybara.git

hani@hanis-lucid:~/rails-proj/bem(master) $ git submodule add git://github.com/jnicklas/capybara.git vendor/cache/git/capybara

'vendor/cache/git/capybara' already exists in the index

As you can see, just doing a git submodule add, will not do it, so we may have to do a git submodule update.

hani@hanis-lucid:~/rails-proj/bem(master) $ git submodule update git://github.com/jnicklas/capybara.git vendor/cache/git/capybara

error: pathspec 'git:/github.com/jnicklas/capybara.git' did not match any file(s) known to git.

Did you forget to 'git add'?

Submodule path 'vendor/cache/git/capybara' not initialized

Maybe you want to use 'update --init'?

hani@hanis-lucid:~/rails-proj/bem(master) $ git submodule

-65ba487d229fda3be85aa88377ab3f435075b2f2 vendor/cache/git/capybara

hani@hanis-lucid:~/rails-proj/bem(master) $ git submodule update vendor/cache/git/capybara/

Submodule path 'vendor/cache/git/capybara' not initialized

Maybe you want to use 'update --init'?

hani@hanis-lucid:~/rails-proj/bem(master) $ git submodule update --init vendor/cache/git/capybara/

Submodule 'vendor/cache/git/capybara' (git://github.com/jnicklas/capybara.git) registered for path 'vendor/cache/git/capybara'

Initialized empty Git repository in /home/hani/rails-proj/bem/vendor/cache/git/capybara/.git/

remote: Counting objects: 6423, done.

remote: Compressing objects: 100% (2623/2623), done.

remote: Total 6423 (delta 4322), reused 5752 (delta 3760)

Receiving objects: 100% (6423/6423), 5.72 MiB | 80 KiB/s, done.

Resolving deltas: 100% (4322/4322), done.

Submodule path 'vendor/cache/git/capybara': checked out '65ba487d229fda3be85aa88377ab3f435075b2f2'

hani@hanis-lucid:~/rails-proj/bem(master) $

hani@hanis-lucid:~/rails-proj/bem(master) $  # HURRAY SUCCESS

hani@hanis-lucid:~/rails-proj/bem(master) $ git status

# On branch master

nothing to commit (working directory clean)

hani@hanis-lucid:~/rails-proj/bem(master) $ bundle

Using rake (0.8.7)

Using abstract (1.0.0)

Using activesupport (3.0.3)

Using builder (2.1.2)

Using i18n (0.5.0)

Using activemodel (3.0.3)

Using erubis (2.6.6)

Using rack (1.2.2)

Using rack-mount (0.6.14)

Using rack-test (0.5.7)

Using tzinfo (0.3.26)

Using actionpack (3.0.3)

Using mime-types (1.16)

Using polyglot (0.3.1)

Using treetop (1.4.9)

Using mail (2.2.17)

Using actionmailer (3.0.3)

Using arel (2.0.9)

Using activerecord (3.0.3)

Using activeresource (3.0.3)

Using annotate-models (1.0.4)

Using bundler (1.0.7)

Using highline (1.6.1)

Using net-ssh (2.1.4)

Using net-scp (1.0.4)

Using net-sftp (2.0.5)

Using net-ssh-gateway (1.0.1)

Using capistrano (2.5.21)

Using capistrano-ext (1.2.1)

Using nokogiri (1.4.4)

Using ffi (1.0.7)

Using childprocess (0.1.8)

Using json_pure (1.5.1)

Using rubyzip (0.9.4)

Using selenium-webdriver (0.2.0)

Using xpath (0.1.4)

Using capybara (1.0.0.beta1) from source at vendor/cache/git/capybara

Using configuration (1.2.0)

Using crack (0.1.8)

Using diff-lcs (1.1.2)

Using json (1.5.1)

Using gherkin (2.3.6)

Using term-ansicolor (1.0.5)

Using cucumber (0.10.2)

Using cucumber-rails (0.4.1)

Using database_cleaner (0.6.7)

Using factory_girl (1.3.3)

Using thor (0.14.6)

Using railties (3.0.3)

Using factory_girl_rails (1.0.1)

Using faker (0.9.5)

Using haml (3.0.25)

Using launchy (0.4.0)

Using rest-client (1.6.1)

Using heroku (1.6.3)

Using looksee (1.0.2)

Using mysql2 (0.2.7)

Using pickle (0.4.7)

Using pickler (0.2.0)

Using rails (3.0.3)

Using rspec-core (2.5.1)

Using rspec-expectations (2.5.0)

Using rspec-mocks (2.5.0)

Using rspec (2.5.0)

Using rspec-rails (2.5.0)

Using web-app-theme (0.6.3)

Using will_paginate (3.0.pre2)

Using wirble (0.1.3)

Updating .gem files in vendor/cache

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

hani@hanis-lucid:~/rails-proj/bem(master) $ git status

# On branch master

nothing to commit (working directory clean)

hani@hanis-lucid:~/rails-proj/bem(master) $ rake

….success...

and more importantly, the cap deploy now works:

...

  * executing `bundle:install'

  * executing "ls -x /home/rubywebw/beytelmouneh.com/releases"

        servers: ["beytelmouneh.com"]

        [beytelmouneh.com] executing command

        command finished in 206ms

  * executing "bundle install --gemfile /home/rubywebw/beytelmouneh.com/releases/20110428154246/Gemfile --path /home/rubywebw/beytelmouneh.com/shared/bundle --deployment --quiet --without development test"

        servers: ["beytelmouneh.com"]

        [beytelmouneh.com] executing command

        command finished in 2715ms

...

I used Zubin’s suggestion on this link to solve this problem

http://ryan.mcgeary.org/2011/02/09/vendor-everything-still-applies/

https://github.com/carlhuda/bundler/issues/67    ( it is a known bug)

An alternate solution, i.e without git submodule from above link:

Just in case anyone needs a temporary workaround before this issue gets resolved, you can check out the git repositories you need at the refs that you need and then add the gems to you gemfile.

For example:

cd vendor/git

git clone git://github.com/foo/foo.git

Then, in your Gemfile, gem "foo", :path => "vendor/git/foo".