Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Gems with Bundler == Big problem

If I run bundle install , everything passes. I reboot nginx, and when I visit the site I see the passenger error with this :

git://github.com/spree/spree.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

My gemfile :

source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem 'spree', :git => 'git://github.com/spree/spree.git' 
gem 'haml'
gem 'ruby-debug'
gem 'sqlite3', :require => 'sqlite3'
gem 'ckeditor', '3.4.2.pre'
gem "aged_revolt", :require => "aged_revolt", :path => "aged_revolt"
gem "spree_easy_contact", '1.0.2', :path => "#{File.expand_path(__FILE__)}/../vendor/gems/spree_easy_contact-1.0.2"
gem "honeypot-captcha"

When I run bundle show spree :

/home/shadyfront/.rvm/gems/ruby-1.8.7-p330@revolting_gems/bundler/gems/spree-44e4771f3a2a

Any idea how/why this is occuring and how I can get past this ?

This is my nginx.conf :

env               GEM_HOME=/home/shadyfront/.rvm/gems/ruby-1.8.7-p330@revolting_gems;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    access_log  /home/shadyfront/logs/user/access_revolting_age.log  combined;
    error_log   /home/shadyfront/logs/user/error_revolting_age.log   crit;

    include         mime.types;
    passenger_root  /home/shadyfront/webapps/revolting_age/gems/gems/passenger-2.2.15;
    passenger_ruby  /home/shadyfront/webapps/revolting_age/bin/ruby;
    sendfile        on;

    passenger_max_instances_per_app  1;
    rails_spawn_method               conservative;
    passenger_max_pool_size 2;

    server {
        listen             56943;
        passenger_enabled  on;
        root               /home/shadyfront/webapps/revolting_age/releases/20110215175319/public;
        server_name        localhost;
    }
}
like image 637
Trip Avatar asked Feb 15 '11 18:02

Trip


4 Answers

This problem seems to be a bug in either passenger or bundler when dealing with git-based gems. This "solution" (I'm writing vendor instead of vender...) got my passenger running right now:

  1. bundle pack
  2. bundle install --path vendor/cache

I think http://www.ruby-forum.com/topic/213962 is the same issue and it's not resolved as far as I know. May this bug be fixed soon...

like image 197
user562529 Avatar answered Oct 05 '22 10:10

user562529


Are you sure it's not a problem with your version # for spree? There's no such tag or version '0.50.99' that I can see of on github.

Edit:

The only other thing I can think of is that since spree is a container of other gem dependencies, bundler doesn't like you defining the requirement this way.

A git repository SHOULD have at least one file, at the root of the directory containing the gem, with the extension .gemspec. This file MUST contain a valid gem specification, as expected by the gem build command. It MUST NOT have any dependencies, other than on the files in the git repository itself and any built-in functionality of Ruby or Rubygems.

This comes from the manpage for bundler.

like image 33
theIV Avatar answered Oct 05 '22 10:10

theIV


That is because you also have to address where the gem location ( specifically where bundler is installed ) in your nginx start script as well.

bin/start

#!/bin/bash

TMPDIR=/home/shadyfront/webapps/truejersey/tmp GEM_HOME=/home/shadyfront/.rvm/gems/ruby-1.8.7-p330@true /home/shadyfront/webapps/truejersey/nginx/sbin/nginx -p /home/shadyfront/webapps/truejersey/nginx/
like image 27
Trip Avatar answered Oct 05 '22 10:10

Trip


The easiest workaround would be to install all gems locally by running

bundle install --path vendor/bundle

The cleaner way is to keep your gems in their GEM_HOME (which might e.g. be managed by rvm) and point to this directory from vendor/bundle:

Step by step:

  • In your project create a directory vendor/bundle/ruby/
  • From command line create a symlink (replace 2.1.0 with your ruby version):

    ln -s $GEM_HOME 2.1.0
    
  • Make sure that you have a file .bundle/config in your project directory which contains the line

    BUNDLE_PATH: vendor/bundle
    

That's it. You can now continue using 'bundle install' as always but also git gems will be referenced correctly.

like image 43
Joshua Avatar answered Oct 05 '22 10:10

Joshua