Permalink
Browse files

Make sure "bundle *" is called in a clean env

Change-Id: I341c19bf4bd8dc96230a99a017ef5104e48ed698
  • Loading branch information...
1 parent d98f3a5 commit 97ad57079de42449d3942f60f205ab0e196a7b0d Vadim Spivak committed Feb 22, 2012
Showing with 48 additions and 36 deletions.
  1. +1 −1 agent_client/Rakefile
  2. +1 −1 blobstore_client/Rakefile
  3. +16 −25 cli/Rakefile
  4. +1 −1 monit_api/Rakefile
  5. +28 −7 rake/bundler_task.rb
  6. +1 −1 ruby_vim_sdk/Rakefile
View
@@ -27,7 +27,7 @@ end
desc "Build and install Bosh Agent Client into system gems"
task "install" do
- sh("bundle install --local --without test development")
+ Rake::Task["bundler:install"].invoke
gem_helper.install_gem
end
@@ -26,7 +26,7 @@ end
desc "Build and install Blobstore Client into system gems"
task "install" do
- sh("bundle install --local --without test development")
+ Rake::Task["bundler:install"].invoke
gem_helper.install_gem
end
View
@@ -1,5 +1,16 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+$:.unshift(File.expand_path("../../rake", __FILE__))
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
+
require "rubygems"
require "bundler"
+Bundler.setup(:default, :test)
+
+require "bundler_task"
+
+BundlerTask.new
desc "Run specs"
task "spec" => [ "bundler:install:test", "test:spec" ]
@@ -19,36 +30,16 @@ end
desc "Build and install Bosh CLI into system gems"
task "install_head" do
- sh("bundle install --local --without test development")
+ Rake::Task["bundler:install"].invoke
gem_helper.install_gem
end
+desc "Install latest stable version into system gems"
task "install" do
- sh("bundle install --local --without test development")
- system("gem install bosh_cli-current.gem")
-end
-
-namespace "bundler" do
- desc "Install gems"
- task "install" do
- sh("bundle install")
+ Rake::Task["bundler:install"].invoke
+ Bundler.with_clean_env do
+ system("gem install bosh_cli-current.gem")
end
-
- environments = %w(test development production)
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- Bundler.with_clean_env do
- #FIXME: this magic won't be needed with Bundler 1.1
- if ENV.has_key? 'RUBYOPT'
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
- end
- sh("bundle install --local --without #{(environments - [env]).join(' ')}")
- end
- end
- end
-
end
namespace "test" do
View
@@ -26,7 +26,7 @@ end
desc "Build and install Monit API Client into system gems"
task "install" do
- sh("bundle install --local --without test development")
+ Rake::Task["bundler:install"].invoke
gem_helper.install_gem
end
View
@@ -2,12 +2,39 @@
require "rake/tasklib"
+# HACK to get a clean ENV from Bundler. (already in Bundler 1.1+)
+if Gem::Version.new(Bundler::VERSION) < Gem::Version.new("1.1.0")
+ module Bundler
+ class << self
+ def with_original_env
+ bundled_env = ENV.to_hash
+ ENV.replace(ORIGINAL_ENV)
+ yield
+ ensure
+ ENV.replace(bundled_env.to_hash)
+ end
+
+ def with_clean_env
+ with_original_env do
+ ENV.delete_if { |k, _| k[0, 7] == "BUNDLE_" }
+ if ENV.has_key?("RUBYOPT")
+ ENV["RUBYOPT"] = ENV["RUBYOPT"].sub("-rbundler/setup", "")
+ end
+ yield
+ end
+ end
+ end
+ end
+end
+
class BundlerTask < ::Rake::TaskLib
def initialize
namespace "bundler" do
desc "Install gems"
task "install" do
- sh("bundle install")
+ Bundler.with_clean_env do
+ sh("bundle install")
+ end
end
environments = %w(test development production)
@@ -16,12 +43,6 @@ def initialize
desc "Install gems for #{env}"
task "install:#{env}" do
Bundler.with_clean_env do
- if ENV.has_key? "RUBYOPT"
- ENV["RUBYOPT"] = ENV["RUBYOPT"].sub("-rbundler/setup", "")
- ENV["RUBYOPT"] = ENV["RUBYOPT"].sub(
- "-I#{File.expand_path("..", __FILE__)}", "")
- end
-
sh("bundle install --without #{(environments - [env]).join(" ")}")
end
end
View
@@ -26,7 +26,7 @@ end
desc "Build and install Ruby VIM Client into system gems"
task "install" do
- sh("bundle install --local --without test development")
+ Rake::Task["bundler:install"].invoke
gem_helper.install_gem
end

0 comments on commit 97ad570

Please sign in to comment.