[Cruisecontrolrb-users] Bundler and cruisecontrol.rb

21 views
Skip to first unread message

Todd Sedano

unread,
Jul 14, 2010, 11:29:32 AM7/14/10
to cruisecont...@rubyforge.org

I'm switching to Bundler for a rails 2.3 project. Is there anything magical that I should do on my CI machine? I did do a "sudo gem install bundler." I'm guessing that I want to do a "bundle install" each time there is a source code change, or even better, a change to the Gemfile. Should I modify my preinitializer.rb ?

I tried the following, but I still need to periodically log into the machine, cd into .cruise/projects/NAME/work and run bundle install.

Any thoughts?

Modifying cruise.rake like this should help..... maybe we can add this to the documentation?

require 'rubygems'
require 'rake'
require 'fileutils'
require "bundler"

desc "Task for cruise Control"
task :cruise do
RAILS_ENV = ENV['RAILS_ENV'] = 'test'

sh "bundle install"
Bundler.setup(:default, :test)


Chad Woolley

unread,
Jul 14, 2010, 8:01:26 PM7/14/10
to cruisecont...@rubyforge.org

I'm not sure if this is a problem with bundler or not, but we run
'bundle install' in a separate parallel interpreter session kicked off
before the tests run (in their own process). Historically (e.g. with
config.gems or geminstaller) , this was necessary to ensure that the
RubyGems cache was not out of date and missing newly-installed gems.
Bundler may not have that problem, though.

Can anyone prove or disprove that you need to run 'bundle install' in
a separate process from your tests?

-- Chad
_______________________________________________
Cruisecontrolrb-users mailing list
Cruisecont...@rubyforge.org
http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users

Todd Sedano

unread,
Sep 24, 2010, 6:25:03 PM9/24/10
to cruisecont...@rubyforge.org
Chad,

Could you provide an example on how to run bundle install from a separate parallel interpreter session kicked off before the tests run? Is this done from the cruise.rake file ?

Thanks,

Todd

Chad Woolley

unread,
Sep 24, 2010, 6:48:26 PM9/24/10
to Todd Sedano, cruisecont...@rubyforge.org
On Fri, Sep 24, 2010 at 3:25 PM, Todd Sedano <todd....@sv.cmu.edu> wrote:
> Chad,
> Could you provide an example on how to run bundle install from a separate
> parallel interpreter session kicked off before the tests run? Is this done
> from the cruise.rake file ?
> Thanks,
> Todd

In a Rails 2.x app, it can be done from cruise.rake, I think it also
works from preinitializer.rb. Just put it in a 'system' call.

Your best bet is to read up on http://gembundler.com/ and ask on the
bundler mailing list if you still have questions. I might tell you
something outdated, as I haven't played with Bundler much since 1.0 :)

Todd Sedano

unread,
Sep 28, 2010, 3:55:12 PM9/28/10
to Chad Woolley, cruisecont...@rubyforge.org
Chad,

I wanted to make sure that I understood your suggestion. I tried to call bundler through a systems call using the "back tick" or `bundle install`  (see below) but that didn't work.

I believe the main issue is that I need to run bundle install before any of the rake files are executed or call my rake file with "bundle exec rake ..." 

I'm hoping you can point me in the right direction in the code to make either modification. Maybe the easiest thing to do is to set project.build_command to a shell script. Other than bundle install, what would I put in my shell script to get cruise control to execute what it currently does? (I'm guessing it is a call to cc_build.rake with some arguments.)


lib/tasks/cruise.rake
require 'rubygems'
require 'rake'
require 'fileutils'
require 'bundler'

desc "Task for cruise Control"
task :cruise do
  RAILS_ENV = ENV['RAILS_ENV'] = 'test'

  `bundle install`  
  Bundler.setup(:default, :test)

  ...

end  

Chad Woolley

unread,
Sep 28, 2010, 4:09:16 PM9/28/10
to Todd Sedano, cruisecont...@rubyforge.org

Yeah, like I said I'm kinda vague on this. But you DON'T necessarily
need to run bundle install BEFORE cruise.rake executes, but you DO
need to run it before rails loads the environment (which happens when
you run a rails rake task. So what you have may be ok, if the '...'
turns into something like "system('rake default') or raise 'rake
failed'"

I THINK that in rails 2.x, calling bundle install from
preinitializer.rb (which runs before environment actually loads)
should accomplish the same thing - even though it gets run twice (a
quirk of rails 2.x init).

Again, I'm almost positive there's some good rails 2.x + bundler docs
on the bundler site which are relevant to the latest 1.x bundler
release, including what you need to stick in preinitializer.rb. And
the bundler list is a better place to ask this stuff (and please feel
free to follow up here with a definitive answer).

Good luck,

Todd Sedano

unread,
Sep 28, 2010, 4:49:54 PM9/28/10
to Chad Woolley, cruisecont...@rubyforge.org
For the next person who wants to get cruise control to work with bundler (in a hurry) here's what I did to solve my issue:

a) modified my the project to use the shell command (project/cruise_config.rb)
  project.build_command = '../build_my_app.sh'

b) created a project/build_my_app.sh with the contents
bundle install
ruby -e "require 'rubygems' rescue nil; require 'rake'; load '/Users/tsedano/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV << '--nosearch' << 'cc:build'; Rake.application.run; ARGV.clear" 


Chad,

I thank you for your help and I was very tempted to call, but didn't want to interrupt your day. 

Thanks for the pointer to the Bundler website. All our projects have followed the directions on this page: http://gembundler.com/rails23.html -- I'm sure there is a way to force bundle install to run everytime that rails is started up, but I didn't want to slow down the development teams.

Here is the reason I think I need to call bundle install before the cruise control rake file gets started, I see the error message:

ruby -e "require 'rubygems' rescue nil; require 'rake'; load '/Users/tsedano/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV << '--nosearch' << 'cc:build'; Rake.application.run; ARGV.clear" rake aborted! 

Bundler couldn't find some gems.Did you run `bundle install`?


The way I read this error, I think it means that the default cruise control rake is failing and needs bundler to run before it even gets to my rake task for the project. I am not a cruise control developer. so I could be wrong. There could be a more elegant way to solve this. I was hoping that modifying cruisecontrol-1.4.0/tasks/cc_build.rake, but it didn't work for me. 


Chad Woolley

unread,
Sep 28, 2010, 5:23:29 PM9/28/10
to Todd Sedano, cruisecont...@rubyforge.org
On Tue, Sep 28, 2010 at 1:49 PM, Todd Sedano <todd....@sv.cmu.edu> wrote:
> For the next person who wants to get cruise control to work with bundler (in
> a hurry) here's what I did to solve my issue:
> a) modified my the project to use the shell command
> (project/cruise_config.rb)
>   project.build_command = '../build_my_app.sh'
> b) created a project/build_my_app.sh with the contents
> bundle install
> ruby -e "require 'rubygems' rescue nil; require 'rake'; load
> '/Users/tsedano/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV <<
> '--nosearch' << 'cc:build'; Rake.application.run; ARGV.clear"
>
> Chad,
> I thank you for your help and I was very tempted to call, but didn't want to
> interrupt your day.
> Thanks for the pointer to the Bundler website. All our projects have
> followed the directions on this page: http://gembundler.com/rails23.html --
> I'm sure there is a way to force bundle install to run everytime that rails
> is started up, but I didn't want to slow down the development teams.

The way we get around this it to check an environment variable -
"IS_CI_BOX" - in preinitializer.rb. We only run bundle install if
this is true. So, developers have to run it manually, but it always
runs on CI.


> Here is the reason I think I need to call bundle install before the cruise
> control rake file gets started, I see the error message:
>
> ruby -e "require 'rubygems' rescue nil; require 'rake'; load
> '/Users/tsedano/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV <<
> '--nosearch' << 'cc:build'; Rake.application.run; ARGV.clear" rake aborted!
>
> Bundler couldn't find some gems.Did you run `bundle install`?

Bundler has to be trying to run before it installs gems. This is
probably because you didn't call 'bundle install' in
preinitializer.rb. You can debug this pretty easily, put some debug
statments into preinitializer.rb and make sure 'bundle install' runs
before your rails environment (and bundler) attempts to set up the
load path.

>
> The way I read this error, I think it means that the default cruise control
> rake is failing and needs bundler to run before it even gets to my rake task
> for the project. I am not a cruise control developer. so I could be wrong.
> There could be a more elegant way to solve this. I was hoping that modifying
> cruisecontrol-1.4.0/tasks/cc_build.rake, but it didn't work for me.
>

Reply all
Reply to author
Forward
0 new messages