Skip to content

Commit

Permalink
Merge pull request #488 from heroku/schneems/fuuuuuuuuuuuu-ruby-versi…
Browse files Browse the repository at this point in the history
…on-specifiers

Revert "Revert "Bump bundler 1.12.5""
  • Loading branch information
schneems committed May 31, 2016
2 parents 088683a + 0ec1928 commit cdef996
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,7 @@
## Master

* Bump bundler to 1.12.5 [Bundler changfelog](https://github.com/bundler/bundler/blob/master/CHANGELOG.md#1123-2016-05-06). Allows for use of Ruby version operators.

## v146 (03/23/2016)

* Warn when `.bundle/config` is checked in (#471)
Expand Down
4 changes: 3 additions & 1 deletion hatchet.json
Expand Up @@ -14,10 +14,12 @@
],
"bundler": [
"sharpstone/bad_gemfile_on_platform",
"sharpstone/problem_gemfile_version",
"sharpstone/git_gemspec",
"sharpstone/no_lockfile",
"sharpstone/sqlite3_gemfile",
"sharpstone/nokogiri_160"
"sharpstone/nokogiri_160",
"sharpstone/bundle-ruby-version-not-in-lockfile"
],
"ruby": [
"sharpstone/mri_187",
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/fetcher.rb
Expand Up @@ -31,7 +31,7 @@ def fetch_bunzip2(path, files_to_extract = nil)

private
def curl_command(command)
"set -o pipefail; curl -L --fail --retry 3 --retry-delay 1 --connect-timeout #{curl_connect_timeout_in_seconds} --max-time #{curl_timeout_in_seconds} #{command}"
"set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout #{curl_connect_timeout_in_seconds} --max-time #{curl_timeout_in_seconds} #{command}"
end

def curl_timeout_in_seconds
Expand Down
43 changes: 24 additions & 19 deletions lib/language_pack/ruby.rb
Expand Up @@ -14,7 +14,7 @@ class LanguagePack::Ruby < LanguagePack::Base
NAME = "ruby"
LIBYAML_VERSION = "0.1.6"
LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}"
BUNDLER_VERSION = "1.11.2"
BUNDLER_VERSION = "1.12.5"
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
RBX_BASE_URL = "http://binaries.rubini.us/heroku"
NODE_BP_PATH = "vendor/node/bin"
Expand Down Expand Up @@ -334,7 +334,7 @@ def install_ruby
Dir.chdir(build_ruby_path) do
ruby_vm = "ruby"
instrument "ruby.fetch_build_ruby" do
@fetchers[:mri].fetch_untar("#{ruby_version.version.sub(ruby_vm, "#{ruby_vm}-build")}.tgz")
@fetchers[:mri].fetch_untar("#{ruby_version.version_for_download.sub(ruby_vm, "#{ruby_vm}-build")}.tgz")
end
end
end
Expand All @@ -343,7 +343,7 @@ def install_ruby
Dir.chdir(slug_vendor_ruby) do
instrument "ruby.fetch_ruby" do
if ruby_version.rbx?
file = "#{ruby_version.version}.tar.bz2"
file = "#{ruby_version.version_for_download}.tar.bz2"
sha_file = "#{file}.sha1"
@fetchers[:rbx].fetch(file)
@fetchers[:rbx].fetch(sha_file)
Expand All @@ -363,7 +363,7 @@ def install_ruby
FileUtils.rm(file)
FileUtils.rm(sha_file)
else
@fetchers[:mri].fetch_untar("#{ruby_version.version}.tgz")
@fetchers[:mri].fetch_untar("#{ruby_version.version_for_download}.tgz")
end
end
end
Expand All @@ -377,9 +377,9 @@ def install_ruby
run("ln -s ../#{vendor_bin} #{app_bin_dir}")
end

@metadata.write("buildpack_ruby_version", ruby_version.version)
@metadata.write("buildpack_ruby_version", ruby_version.version_for_download)

topic "Using Ruby version: #{ruby_version.version}"
topic "Using Ruby version: #{ruby_version.version_for_download}"
if !ruby_version.set
warn(<<-WARNING)
You have not declared a Ruby version in your Gemfile.
Expand All @@ -392,21 +392,26 @@ def install_ruby

true
rescue LanguagePack::Fetcher::FetchError => error
if ruby_version.jruby?
message = <<ERROR
An error occurred while installing Ruby #{ruby_version.version}
For supported Ruby versions see https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
Note: Only JRuby 1.7.13 and newer are supported on Cedar-14
#{error.message}
ERROR
else
message = <<ERROR
An error occurred while installing Ruby #{ruby_version.version}
For supported Ruby versions see https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
Note: Only the most recent version of Ruby 2.1 is supported on Cedar-14
#{error.message}
message = <<ERROR
An error occurred while installing #{ruby_version.version_for_download}
Heroku recommends you use the latest supported Ruby version listed here:
https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
For more information on syntax for declaring a Ruby version see:
https://devcenter.heroku.com/articles/ruby-versions
ERROR

if ruby_version.jruby?
message << "Note: Only JRuby 1.7.13 and newer are supported on Cedar-14"
elsif ruby_version.ruby_version.start_with?("2.1")
message << "Note: Only the most recent version of Ruby 2.1 is supported on Cedar-14\n"
end

message << "\nDebug Information"
message << error.message

error message
end

Expand Down
15 changes: 15 additions & 0 deletions lib/language_pack/ruby_version.rb
Expand Up @@ -38,6 +38,21 @@ def initialize(bundler_output, app = {})
@version_without_patchlevel = @version.sub(/-p[\d]+/, '')
end

# https://github.com/bundler/bundler/issues/4621
def version_for_download
if patchlevel_is_significant?
@version
else
version_without_patchlevel
end
end

# Before Ruby 2.1 patch releases were done via patchlevel i.e. 1.9.3-p426 versus 1.9.3-p448
# With 2.1 and above patches are released in the "minor" version instead i.e. 2.1.0 versus 2.1.1
def patchlevel_is_significant?
Gem::Version.new(self.ruby_version) <= Gem::Version.new("2.1")
end

def rake_is_vendored?
Gem::Version.new(self.ruby_version) >= Gem::Version.new("1.9")
end
Expand Down
9 changes: 9 additions & 0 deletions spec/helpers/bundler_wrapper_spec.rb
Expand Up @@ -30,6 +30,15 @@
@bundler.install
end

it "handles apps with ruby versions locked in Gemfile.lock" do
Hatchet::App.new("problem_gemfile_version").in_directory do |dir|
expect(@bundler.ruby_version).to eq("ruby-2.3.0-p0")

ruby_version = LanguagePack::RubyVersion.new(@bundler.ruby_version, is_new: true)
expect(ruby_version.version_for_download).to eq("ruby-2.3.0")
end
end

it "handles JRuby pre gemfiles" do
Hatchet::App.new("jruby-minimal").in_directory do |dir|
expect(@bundler.ruby_version).to eq("ruby-2.2.0-jruby-9.0.0.0.pre1")
Expand Down
1 change: 0 additions & 1 deletion spec/rails4_spec.rb
Expand Up @@ -40,7 +40,6 @@
# Hatchet::Runner.new("rails4_windows_mri193").deploy do |app, heroku|
# result = app.run("rails -v")
# expect(result).to match("4.0.0")

# result = app.run("rake -T")
# expect(result).to match("assets:precompile")

Expand Down
14 changes: 14 additions & 0 deletions spec/ruby_spec.rb
@@ -1,6 +1,20 @@
require_relative 'spec_helper'

describe "Ruby apps" do
describe "bundler ruby version matcher" do
it "installs a version even when not present in the Gemfile.lock" do
Hatchet::Runner.new('bundle-ruby-version-not-in-lockfile').deploy do |app|
expect(app.output).to match("2.3.1")
expect(app.run("ruby -v")).to match("2.3.1")
end
end

it "works even when patchfile is specified" do
Hatchet::Runner.new('problem_gemfile_version').deploy do |app|
expect(app.output).to match("2.3.0")
end
end
end

# describe "default WEB_CONCURRENCY" do
# it "auto scales WEB_CONCURRENCY" do
Expand Down

0 comments on commit cdef996

Please sign in to comment.