summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-02-10 16:02:35 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-02-10 16:02:35 -0800
commitf7bfddea609fcd568e0082809af3214457553630 (patch)
tree4e9c61b8e24746202fa52504adbc0819ba263b49
parent6c5a67dc849e7ed4dc1fc05176afcf6ae61ec776 (diff)
downloadbundler-f7bfddea609fcd568e0082809af3214457553630.tar.gz
Actually disable system gems in .bundle/environment.rb
-rw-r--r--bundler.gemspec4
-rw-r--r--lib/bundler.rb1
-rw-r--r--lib/bundler/runtime.rb15
-rw-r--r--lib/bundler/shared_helpers.rb19
-rw-r--r--lib/bundler/templates/environment.erb7
-rw-r--r--spec/runtime/environment_rb_spec.rb26
-rw-r--r--spec/runtime/require_spec.rb1
-rw-r--r--spec/support/helpers.rb15
8 files changed, 66 insertions, 22 deletions
diff --git a/bundler.gemspec b/bundler.gemspec
index 7bd310e99c..a80a8bfa17 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
s.authors = ["Carl Lerche", "Yehuda Katz"]
- s.date = %q{2010-02-07}
+ s.date = %q{2010-02-10}
s.default_executable = %q{bundle}
s.email = ["carlhuda@engineyard.com"]
s.executables = ["bundle"]
- s.files = ["bin/bundle", "lib/bundler", "lib/bundler/cli.rb", "lib/bundler/definition.rb", "lib/bundler/dependency.rb", "lib/bundler/dsl.rb", "lib/bundler/environment.rb", "lib/bundler/index.rb", "lib/bundler/installer.rb", "lib/bundler/remote_specification.rb", "lib/bundler/resolver.rb", "lib/bundler/rubygems-ext.rb", "lib/bundler/runtime.rb", "lib/bundler/settings.rb", "lib/bundler/setup.rb", "lib/bundler/source.rb", "lib/bundler/specification.rb", "lib/bundler/templates", "lib/bundler/templates/environment.erb", "lib/bundler/templates/Gemfile", "lib/bundler/ui.rb", "lib/bundler/vendor", "lib/bundler/vendor/thor", "lib/bundler/vendor/thor/base.rb", "lib/bundler/vendor/thor/core_ext", "lib/bundler/vendor/thor/core_ext/file_binary_read.rb", "lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb", "lib/bundler/vendor/thor/core_ext/ordered_hash.rb", "lib/bundler/vendor/thor/error.rb", "lib/bundler/vendor/thor/invocation.rb", "lib/bundler/vendor/thor/parser", "lib/bundler/vendor/thor/parser/argument.rb", "lib/bundler/vendor/thor/parser/arguments.rb", "lib/bundler/vendor/thor/parser/option.rb", "lib/bundler/vendor/thor/parser/options.rb", "lib/bundler/vendor/thor/parser.rb", "lib/bundler/vendor/thor/shell", "lib/bundler/vendor/thor/shell/basic.rb", "lib/bundler/vendor/thor/shell/color.rb", "lib/bundler/vendor/thor/shell.rb", "lib/bundler/vendor/thor/task.rb", "lib/bundler/vendor/thor/util.rb", "lib/bundler/vendor/thor/version.rb", "lib/bundler/vendor/thor.rb", "lib/bundler.rb", "LICENSE", "README.markdown"]
+ s.files = ["bin/bundle", "lib/bundler", "lib/bundler/cli.rb", "lib/bundler/definition.rb", "lib/bundler/dependency.rb", "lib/bundler/dsl.rb", "lib/bundler/environment.rb", "lib/bundler/index.rb", "lib/bundler/installer.rb", "lib/bundler/remote_specification.rb", "lib/bundler/resolver.rb", "lib/bundler/rubygems-ext.rb", "lib/bundler/runtime.rb", "lib/bundler/settings.rb", "lib/bundler/setup.rb", "lib/bundler/shared_helpers.rb", "lib/bundler/source.rb", "lib/bundler/specification.rb", "lib/bundler/templates", "lib/bundler/templates/environment.erb", "lib/bundler/templates/Gemfile", "lib/bundler/ui.rb", "lib/bundler/vendor", "lib/bundler/vendor/thor", "lib/bundler/vendor/thor/base.rb", "lib/bundler/vendor/thor/core_ext", "lib/bundler/vendor/thor/core_ext/file_binary_read.rb", "lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb", "lib/bundler/vendor/thor/core_ext/ordered_hash.rb", "lib/bundler/vendor/thor/error.rb", "lib/bundler/vendor/thor/invocation.rb", "lib/bundler/vendor/thor/parser", "lib/bundler/vendor/thor/parser/argument.rb", "lib/bundler/vendor/thor/parser/arguments.rb", "lib/bundler/vendor/thor/parser/option.rb", "lib/bundler/vendor/thor/parser/options.rb", "lib/bundler/vendor/thor/parser.rb", "lib/bundler/vendor/thor/shell", "lib/bundler/vendor/thor/shell/basic.rb", "lib/bundler/vendor/thor/shell/color.rb", "lib/bundler/vendor/thor/shell.rb", "lib/bundler/vendor/thor/task.rb", "lib/bundler/vendor/thor/util.rb", "lib/bundler/vendor/thor/version.rb", "lib/bundler/vendor/thor.rb", "lib/bundler.rb", "LICENSE", "README.markdown"]
s.homepage = %q{http://github.com/carlhuda/bundler}
s.post_install_message = %q{Due to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work}
s.require_paths = ["lib"]
diff --git a/lib/bundler.rb b/lib/bundler.rb
index b5465711c6..6154efe66f 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -16,6 +16,7 @@ module Bundler
autoload :Resolver, 'bundler/resolver'
autoload :Runtime, 'bundler/runtime'
autoload :Settings, 'bundler/settings'
+ autoload :SharedHelpers, 'bundler/shared_helpers'
autoload :Source, 'bundler/source'
autoload :Specification, 'bundler/specification'
autoload :UI, 'bundler/ui'
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 8925dab975..56205a06df 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -2,6 +2,8 @@ require "digest/sha1"
module Bundler
class Runtime < Environment
+ include SharedHelpers
+
def setup(*groups)
# Has to happen first
clean_load_path
@@ -109,6 +111,7 @@ module Bundler
end
def write_rb_lock
+ shared_helpers = File.read(File.expand_path("../shared_helpers.rb", __FILE__))
template = File.read(File.expand_path("../templates/environment.erb", __FILE__))
erb = ERB.new(template, nil, '-')
File.open("#{root}/.bundle/environment.rb", 'w') do |f|
@@ -174,18 +177,6 @@ module Bundler
end
end
- def reverse_rubygems_kernel_mixin
- # Disable rubygems' gem activation system
- ::Kernel.class_eval do
- if private_method_defined?(:gem_original_require)
- alias rubygems_require require
- alias require gem_original_require
- end
-
- undef gem
- end
- end
-
def cripple_rubygems(specs)
reverse_rubygems_kernel_mixin
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
new file mode 100644
index 0000000000..a50541680e
--- /dev/null
+++ b/lib/bundler/shared_helpers.rb
@@ -0,0 +1,19 @@
+module Bundler
+ module SharedHelpers
+
+ def reverse_rubygems_kernel_mixin
+ require "rubygems"
+
+ # Disable rubygems' gem activation system
+ ::Kernel.class_eval do
+ if private_method_defined?(:gem_original_require)
+ alias rubygems_require require
+ alias require gem_original_require
+ end
+
+ undef gem
+ end
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/bundler/templates/environment.erb b/lib/bundler/templates/environment.erb
index a3d555758d..404ebd681e 100644
--- a/lib/bundler/templates/environment.erb
+++ b/lib/bundler/templates/environment.erb
@@ -1,7 +1,14 @@
require 'digest/sha1'
# DO NOT MODIFY THIS FILE
+
+<%= shared_helpers %>
+
module Bundler
+ extend SharedHelpers
+
+ reverse_rubygems_kernel_mixin
+
FINGERPRINT = <%= gemfile_fingerprint.inspect %>
LOAD_PATHS = <%= load_paths.inspect %>
AUTOREQUIRES = <%= autorequires_for_groups.inspect %>
diff --git a/spec/runtime/environment_rb_spec.rb b/spec/runtime/environment_rb_spec.rb
new file mode 100644
index 0000000000..d61df42aa7
--- /dev/null
+++ b/spec/runtime/environment_rb_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe "environment.rb file" do
+ it "does not pull in system gems" do
+ system_gems "rack-1.0.0"
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "activesupport"
+ G
+
+ bundle :lock
+
+ run <<-R, :lite_runtime => true
+ require 'rubygems'
+ begin;
+ require 'rack'
+ rescue LoadError
+ puts 'WIN'
+ end
+ R
+
+ out.should == "WIN"
+ end
+end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index d53e5e4cfd..bb79b74673 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -47,7 +47,6 @@ describe "Bundler.require" do
bundle :lock
out = ruby("require 'bundler'; Bundler.setup; Bundler.require")
- puts out
out.should == "two"
out = ruby("require 'bundler'; Bundler.setup(:bar); Bundler.require(:bar)")
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 9292a97b67..88b9fc63bb 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -21,15 +21,16 @@ module Spec
Dir.chdir(bundled_app2, &blk)
end
- def run_in_context(cmd)
- env = bundled_path.join('environment.rb')
- raise "Missing environment.rb" unless env.file?
- @out = ruby "-r #{env}", cmd
- end
-
def run(cmd, *args)
+ opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map {|a| a.inspect }.join(", ")
- setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
+
+ if opts[:lite_runtime]
+ setup = "require '#{bundled_app(".bundle/environment")}' ; Bundler.setup(#{groups})\n"
+ else
+ setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
+ end
+
@out = ruby(setup + cmd)
end