diff --git a/README.md b/README.md index e300de875..4cb379d45 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,17 @@ For more information about using Ruby and buildpacks on Heroku, see these Dev Ce To use this buildpack, fork it on Github. Push up changes to your fork, then create a test app with `--buildpack ` and push to it. + +## Next Rails + +This buildpack supports Next Rails version, to configure it follow the steps below: + +1. Make sure your app can boot with the next Rails version locally. +2. Go to the Settings tab of your Heroku app, and add the `BUNDLE_GEMFILE` config var with `Gemfile.next` as a value. +3. Go to the Buildpacks section and remove the `heroku/ruby` buildpack from your app and add `https://github.com/fastruby/heroku-buildpack-ruby#add_gemfile_next_support` +4. Deploy your app to Heroku. +5. The Next Rails version should be installed and your app should boot. + ### Testing The tests on this buildpack are written in Rspec to allow the use of diff --git a/lib/language_pack/helpers/bundler_wrapper.rb b/lib/language_pack/helpers/bundler_wrapper.rb index fe9bd70b8..d79166300 100644 --- a/lib/language_pack/helpers/bundler_wrapper.rb +++ b/lib/language_pack/helpers/bundler_wrapper.rb @@ -101,7 +101,7 @@ def initialize(version_hash, major_minor) def initialize(options = {}) @bundler_tmp = Pathname.new(Dir.mktmpdir) @fetcher = options[:fetcher] || LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL) # coupling - @gemfile_path = options[:gemfile_path] || Pathname.new("./Gemfile") + @gemfile_path = options[:gemfile_path] || Pathname.new(env("BUNDLE_GEMFILE") || "./Gemfile") @gemfile_lock_path = Pathname.new("#{@gemfile_path}.lock") @version = self.class.detect_bundler_version(contents: @gemfile_lock_path.read(mode: "rt")) @@ -223,7 +223,7 @@ def needs_ruby_global_append_path? end def bundler_version_escape_valve! - topic("Removing BUNDLED WITH version in the Gemfile.lock") + topic("Removing BUNDLED WITH version in the #{@gemfile_lock_path}") contents = File.read(@gemfile_lock_path, mode: "rt") File.open(@gemfile_lock_path, "w") do |f| f.write contents.sub(/^BUNDLED WITH$(\r?\n) (?\d+)\.\d+\.\d+/m, '') diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 4a3009b7e..6312f23d4 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -141,7 +141,7 @@ def build build_bundler # TODO post_bundler might need to be done in a new layer bundler.clean - gem_layer.metadata[:gems] = Digest::SHA2.hexdigest(File.read("Gemfile.lock")) + gem_layer.metadata[:gems] = Digest::SHA2.hexdigest(File.read(gemfile_lock_path)) gem_layer.metadata[:stack] = @stack gem_layer.metadata[:ruby_version] = run_stdout(%q(ruby -v)).strip gem_layer.metadata[:rubygems_version] = run_stdout(%q(gem -v)).strip @@ -759,7 +759,7 @@ def build_bundler if bundler.windows_gemfile_lock? log("bundle", "has_windows_gemfile_lock") - File.unlink("Gemfile.lock") + File.unlink(gemfile_lock_path) ENV.delete("BUNDLE_DEPLOYMENT") warn(<<~WARNING, inline: true) @@ -796,7 +796,7 @@ def build_bundler # we need to set BUNDLE_CONFIG and BUNDLE_GEMFILE for # codon since it uses bundler. - env_vars["BUNDLE_GEMFILE"] = "#{pwd}/Gemfile" + env_vars["BUNDLE_GEMFILE"] = "#{pwd}/#{gemfile_path}" env_vars["BUNDLE_CONFIG"] = "#{pwd}/.bundle/config" env_vars["CPATH"] = noshellescape("#{yaml_include}:$CPATH") env_vars["CPPATH"] = noshellescape("#{yaml_include}:$CPPATH") @@ -1325,4 +1325,16 @@ def purge_bundler_cache(stack = nil) # need to reinstall language pack gems install_bundler_in_app(slug_vendor_base) end + + def current_gemfile + env("BUNDLE_GEMFILE") || "Gemfile" + end + + def gemfile_path + Pathname.new(current_gemfile) + end + + def gemfile_lock_path + Pathname.new("#{current_gemfile}.lock") + end end