lib/appbundler/app.rb in appbundler-0.11.5 vs lib/appbundler/app.rb in appbundler-0.11.6
- old
+ new
@@ -224,27 +224,32 @@
# Environment sanitization can be skipped by setting the
# APPBUNDLER_ALLOW_RVM environment variable to "true". This feature
# exists to make tests run correctly on travis.ci (which uses rvm).
def env_sanitizer
<<-EOS
-ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"
require "rubygems"
begin
# this works around rubygems/rubygems#2196 and can be removed in rubygems > 2.7.6
require "rubygems/bundler_version_finder"
rescue LoadError
# probably means rubygems is too old or too new to have this class, and we don't care
end
-::Gem.clear_paths
+# avoid appbundling if we are definitely running within a Bundler bundle.
+# most likely the check for defined?(Bundler) is enough since we don't require
+# bundler above, but just for paranoia's sake also we test to see if Bundler is
+# really doing its thing or not.
+unless defined?(Bundler) && Bundler.instance_variable_defined?("@load")
+ ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"
+ ::Gem.clear_paths
EOS
end
def runtime_activate
@runtime_activate ||= begin
- statements = runtime_dep_specs.map { |s| %Q{gem "#{s.name}", "= #{s.version}"} }
+ statements = runtime_dep_specs.map { |s| %Q{ gem "#{s.name}", "= #{s.version}"} }
activate_code = ""
activate_code << env_sanitizer << "\n"
activate_code << statements.join("\n") << "\n"
activate_code
end
@@ -256,12 +261,15 @@
def load_statement_for(bin_file)
name, version = app_spec.name, app_spec.version
bin_basename = File.basename(bin_file)
<<-E
-gem "#{name}", "= #{version}"
+ gem "#{name}", "= #{version}"
+ spec = Gem::Specification.find_by_name("#{name}", "= #{version}")
+else
+ spec = Gem::Specification.find_by_name("#{name}")
+end
-spec = Gem::Specification.find_by_name("#{name}", "= #{version}")
bin_file = spec.bin_file("#{bin_basename}")
Kernel.load(bin_file)
E
end