lib/appbundler/app.rb in appbundler-0.11.3 vs lib/appbundler/app.rb in appbundler-0.11.4

- old
+ new

@@ -140,13 +140,14 @@ Bundler.with_clean_env do so = Mixlib::ShellOut.new("bundle lock", env: { "BUNDLE_GEMFILE" => t.path }) so.run_command so.error! end + FileUtils.mv t.path, "#{app_dir}/Gemfile" end end - return "#{app_dir}/Gemfile.lock" + return "#{app_dir}/Gemfile" end def write_executable_stubs executables_to_create = executables.map do |real_executable_path| basename = File.basename(real_executable_path) @@ -223,19 +224,28 @@ # 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" -::Gem.clear_paths + +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 + +unless ENV["BUNDLE_GEMFILE"] + 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 @@ -247,12 +257,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