Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-sourced gems don't get loaded via bundler #27

Open
jyurek opened this issue Aug 29, 2011 · 12 comments
Open

git-sourced gems don't get loaded via bundler #27

jyurek opened this issue Aug 29, 2011 · 12 comments

Comments

@jyurek
Copy link

jyurek commented Aug 29, 2011

I have an app that has a gem required through git. When I run the specjour listener with bundle exec specjour listen, the Gemfile isn't loaded correctly. The git-sourced gem simply doesn't load. I get Could not find rack-ssl-enforcer-0.2.0.gem for installation and tests fail because of the missing gem.

@sandro
Copy link
Owner

sandro commented Aug 29, 2011

Would you mind posting the line from your Gemfile? If the git source is local, you should use an absolute path rather than a relative path. The listener executes code (bundle install) from within /tmp.

@jyurek
Copy link
Author

jyurek commented Aug 29, 2011

gem "rack-ssl-enforcer",
    :require => "rack/ssl-enforcer",
    :git     => "git://github.com/pelle/rack-ssl-enforcer.git"

@sandro
Copy link
Owner

sandro commented Aug 30, 2011

I just tried including the above line into my Gemfile, and the gem installed without issue. I double checked the installation by cd'ing into /tmp/<project_name> and running bundle list. Did you bundle install before running the specjour command? Bundle exec doesn't work if gems are missing.

@jyurek
Copy link
Author

jyurek commented Aug 30, 2011

I did bundle install. That's why it's so weird. The bundle install beforehand on the command line works fine, but the one as part of the specjour before_fork doesn't.

Wait, could that be it? If I bundle as part of the after_fork, would that help?

On Aug 30, 2011, at 3:45 AM, [email protected] wrote:

I just tried including the above line into my Gemfile, and the gem installed without issue. I double checked the installation by cd'ing into /tmp/<project_name> and running bundle list. Did you bundle install before running the specjour command? Bundle exec doesn't work if gems are missing.

Reply to this email directly or view it on GitHub:
#27 (comment)

@jyurek
Copy link
Author

jyurek commented Aug 30, 2011

No, that didn't seem to help anything. I just get the bundle error twice now.

@jyurek
Copy link
Author

jyurek commented Aug 30, 2011

For reference, this is my .specjour/hooks.rb file:

Specjour::Configuration.before_fork = lambda do
  system('bundle install')
end

And the error happens if I run the listener with bundle exec specjour listen, then start a normal specjour test run. If I make a gemset and run it without the bundle exec it works better, but that will create maintenance headaches when gems inevitably update later.

@sandro
Copy link
Owner

sandro commented Aug 30, 2011

Do you get the same error when you cd into /tmp/project and run bundle install?

@jyurek
Copy link
Author

jyurek commented Aug 31, 2011

No, I don't get the error. If I try system("cd /tmp/project && bundle install") in my hook I do still get the error.

@jyurek
Copy link
Author

jyurek commented Sep 1, 2011

So, I was thinking about this earlier, and I hit upon the idea that this might not be the right approach to this in the first place. If I have a project that has a Gemfile, what is the expected way for specjour to execute those specs? If the listener is run via bundle exec the versions of the gems won't change unless the listener is restarted. But the specs don't run without it because of gem version conflicts.

Am I just thinking about the problem wrong? What is the expected usage of specjour for this problem?

@sandro
Copy link
Owner

sandro commented Sep 3, 2011

You need to have all of your gem dependencies satisfied in order to run specjour listen. Once the listener is up and running, it calls the before_fork callback before forking out worker processes to run tests. The default behavior of before_fork is to run bundle install within the project directory inside of /tmp. The listener doesn't need to know about updated gems because it never loads the rails environment. It simply prepares the project directory before forking workers.

I don't know why bundle install is failing for you. You could try removing .specjour/hooks as it seems redundant, and is the only difference between what you're doing and what I'm doing.

@jyurek
Copy link
Author

jyurek commented Sep 6, 2011

It appears as though the blame is lying more on bundler, since it won't cache a rack gem... but I can't seem to find out why it only looks in the cache to begin with, and doesn't behave like a normal bundle install does. Removing the hooks doesn't help any.

@pierreozoux
Copy link
Collaborator

@jyurek Did you find a solution to your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants