Installing Gems with Bundler == Big problem
Asked Answered
J

5

9

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;
    }
}
Jessicajessie answered 15/2, 2011 at 18:23 Comment(1)
Which version of passenger? What does your nginx config look like? Have you told it to use the 'revolting_gems' gemset?Massie
J
1

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/
Jessicajessie answered 11/3, 2011 at 13:58 Comment(0)
M
26

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

Marcionism answered 11/3, 2011 at 3:5 Comment(5)
I just stumbled about this again. Definetely the problem is caused by importing from git and it seems as if hundereds of people got this problem. Wondering if someone actually works on fixing this...Marcionism
I had to use this as well. Very annoying. May have to do with the fact that unicorn is running as a different user. Not sure how to resolve it though.Uniflorous
This still works for me in 2016. However when using vagrant and calling vagrant halt / vagrant up, I have to redo this...Deaminate
Thanks, from 2017.Prairie
Holla' from 2023! Bundler is still the posterboy for everything wrong with Ruby. This happens when building using the latest ruby:2.7-buster Docker image. To be fair, it's my fault for forking a Ruby repo and fixing a few bugs in yet another abandoned project left to rot. The most impressive part of the this race condition is that Ruby doesn't even really multithread; it's got an interpreter lock. Forgive the tone, 2 more days of lost productivity because I'm not throwing away my unit tests just yet.Danieladaniele
P
1

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.

Predator answered 15/2, 2011 at 18:36 Comment(7)
I know. So strange. If I put the latest version which is 0.40.2, after bundle install it returns this : Could not find gem 'spree (= 0.40.2, runtime)' in git://github.com/spree/spree.git (at master). Source contains 'spree' at: 0.50.99 And if I do the latter version it passes bundle, but returns the original error.Jessicajessie
You don't need the version number in this case because the repo you're pointing at does have a gemspec, which is reporting version 0.50.99 (see the bundler docs). This is why it breaks when you change it to a different version. It'll break next time they bump the version as well. You should remove it and use :tag or :ref if you want to be more specific about versions.Massie
Would that be why I'm getting spree.git (at master) is not checked out. ?Jessicajessie
Could be. Does it fix the problem if you remove the version number?Massie
No.. haha. I tried messing around the id, ref, and branch tags but they all errored out and wouldn't pass bundle. So like you said, I just removed the version, and ran it it passes. Here comes the strange part. If I set a --path or --deployment tag to bundle, bundle will fail saying that my sqlite3 isn't above a certain version ( which it is. ). Even if the --path is set to my default GEM_HOME. But if I just do bundle install, then it passes, but doesn't run with the error mentioned above with spree not being installed.Jessicajessie
@theIV, great point, but alas even the official spree git says to just add the gem 'spree'.Jessicajessie
Right, though to me at least, from the docs, it seems to be different if you do gem 'spree' as opposed to gem 'spree', :git => 'git://github.com/spree/spree.git'.Predator
J
1

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/
Jessicajessie answered 11/3, 2011 at 13:58 Comment(0)
I
1

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.

Infinitesimal answered 5/3, 2015 at 21:58 Comment(0)
C
0

I faced this problem in Feb 2015 and installing gem locally in project directory fix it for me.

 $ bundle install --path vendor/bundle
Commutator answered 11/2, 2015 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.