Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Actually disable system gems in .bundle/environment.rb

  • Loading branch information...
commit f7bfddea609fcd568e0082809af3214457553630 1 parent 6c5a67d
Carlhuda authored
4 bundler.gemspec
View
@@ -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"]
1  lib/bundler.rb
View
@@ -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'
15 lib/bundler/runtime.rb
View
@@ -2,6 +2,8 @@
module Bundler
class Runtime < Environment
+ include SharedHelpers
+
def setup(*groups)
# Has to happen first
clean_load_path
@@ -109,6 +111,7 @@ def load_paths
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 @@ def clean_load_path
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
19 lib/bundler/shared_helpers.rb
View
@@ -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
7 lib/bundler/templates/environment.erb
View
@@ -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 %>
26 spec/runtime/environment_rb_spec.rb
View
@@ -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
1  spec/runtime/require_spec.rb
View
@@ -47,7 +47,6 @@
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)")
15 spec/support/helpers.rb
View
@@ -21,15 +21,16 @@ def in_app_root2(&blk)
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
Please sign in to comment.
Something went wrong with that request. Please try again.