Skip to content

Commit

Permalink
Remove RBX and "build" support
Browse files Browse the repository at this point in the history
Rubinius is a Ruby implementation that was available to use on the platform a long time ago but has not been supported for some time:

Ruby 1.9.2 requires a "build" branch of logic that can be removed as well. It is not on any existing stacks and was not present on Heroku-18:

```
$ curl -I https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-18/ruby-2.5.7.tgz
HTTP/1.1 200 OK
x-amz-id-2: Hl89PTav6LfvU90vP97YsBc5DEBptax9s4PZU+3ubIrIUBY54lD0f2FXMOCgh9XQEQRU+5ia1x4=
x-amz-request-id: KVDZM54WRBN5ASGT
Date: Mon, 15 Apr 2024 15:55:27 GMT
Last-Modified: Tue, 01 Oct 2019 14:46:30 GMT
ETag: "93ff97625abfc6ccd1a071bb0fda8e66"
x-amz-version-id: null
Accept-Ranges: bytes
Content-Type:
Server: AmazonS3
Content-Length: 11995820
$ curl -I https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-18/ruby-1.9.2.tgz
HTTP/1.1 404 Not Found
x-amz-request-id: 1NKVW4VD3T94T71R
x-amz-id-2: tTow7CFW9BcWmAbkEWvrqPz5zJdsy7ry8Jm39v+EURa4RN/UpslBhhGf1iHzOrpJ4n1BJxiGGoI=
Content-Type: application/xml
Date: Mon, 15 Apr 2024 15:55:31 GMT
Server: AmazonS3
```

Other unused functionality that's being removed:

- CDN support for downloading Ruby binaries. This provided no meaningful download improvement when deploying as the binaries are on S3 in the same data center. This was disabled a long time ago.
- A "default cache" that was warmed with common gems for the most common Ruby version. This was effective at reducing "first build" time but the complexity exploded if we were to try and support N versions of Rails and M versions of Ruby for this feature. Additionally the community has moved to pre-built binaries for some expensive components such as nokogiri.
  • Loading branch information
schneems committed Apr 15, 2024
1 parent 7866d1e commit fc3d81f
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 315 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Remove unused Rubinius and Ruby 1.9.2 codepaths (https://github.com/heroku/heroku-buildpack-ruby/pull/1440)

## [v267] - 2024-02-28

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ RUBY VERSION
ruby 3.1.4p223

BUNDLED WITH
2.3.10
2.5.8
15 changes: 0 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,6 @@ task "gem:install", :gem, :version do |t, args|
install_gem(gem, version)
end

desc "generate ruby versions manifest"
task "ruby:manifest" do
require 'rexml/document'
require 'yaml'

document = REXML::Document.new(`curl https://#{S3_BUCKET_NAME}.s3.#{S3_BUCKET_REGION}.amazonaws.com`)
rubies = document.elements.to_a("//Contents/Key").map {|node| node.text }.select {|text| text.match(/^(ruby|rbx|jruby)-\\\\d+\\\\.\\\\d+\\\\.\\\\d+(-p\\\\d+)?/) }

Dir.mktmpdir("ruby_versions-") do |tmpdir|
name = 'ruby_versions.yml'
File.open(name, 'w') {|file| file.puts(rubies.to_yaml) }
sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name} #{name}")
end
end

begin
require 'rspec/core/rake_task'

Expand Down
1 change: 0 additions & 1 deletion config/cdn.yml

This file was deleted.

4 changes: 0 additions & 4 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"sharpstone/default_with_rakefile"
],
"bundler": [
"sharpstone/bad_gemfile_on_platform",
"sharpstone/problem_gemfile_version",
"sharpstone/git_gemspec",
"sharpstone/no_lockfile",
Expand All @@ -33,9 +32,6 @@
],
"rack": [
"sharpstone/default_ruby",
"sharpstone/mri_187_nokogiri",
"sharpstone/mri_192",
"sharpstone/mri_193",
"sharpstone/mri_200"
],
"rails_versions": [
Expand Down
8 changes: 0 additions & 8 deletions hatchet.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
- - "./repos/bundler/bad_gemfile_on_platform"
- 5dd45c83631f58d121afb48b513016cc9e2d3432
- - "./repos/bundler/git_gemspec"
- 7755e19caf122e1373bce73ffe9b333e9411d732
- - "./repos/bundler/no_lockfile"
Expand Down Expand Up @@ -29,12 +27,6 @@
- 9152fec98df59a0bf8a5478ed428841ee135acbb
- - "./repos/rack/default_ruby"
- master
- - "./repos/rack/mri_187_nokogiri"
- 3fcce9c85bf560dba285cc385ae9845729195826
- - "./repos/rack/mri_192"
- ef6b5ccf8aa2a8f5e3745934e3580dc0bd2d6d4b
- - "./repos/rack/mri_193"
- 2e9ed455517c57b0dc953f54fbf9fef641c7aadb
- - "./repos/rack/mri_200"
- f9922cbd9c6f44fdded54912f66038db37cb4b8f
- - "./repos/rails_versions/active_storage_local"
Expand Down
2 changes: 0 additions & 2 deletions lib/language_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def self.detect(*args)
require "language_pack/helpers/bundler_wrapper"
require "language_pack/helpers/outdated_ruby_version"
require "language_pack/helpers/download_presence"
require "language_pack/installers/ruby_installer"
require "language_pack/installers/heroku_ruby_installer"
require "language_pack/installers/rbx_installer"

require "language_pack/ruby"
require "language_pack/rack"
Expand Down
16 changes: 3 additions & 13 deletions lib/language_pack/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ class Fetcher
class FetchError < StandardError; end

include ShellHelpers
CDN_YAML_FILE = File.expand_path("../../../config/cdn.yml", __FILE__)

def initialize(host_url, stack = nil)
@config = load_config
@host_url = fetch_cdn(host_url)
def initialize(host_url, stack: nil)
@host_url = Pathname.new(host_url)
# File.basename prevents accidental directory traversal
@host_url += File.basename(stack) if stack
end

Expand Down Expand Up @@ -50,14 +49,5 @@ def curl_timeout_in_seconds
def curl_connect_timeout_in_seconds
env('CURL_CONNECT_TIMEOUT') || 3
end

def load_config
YAML.load_file(CDN_YAML_FILE) || {}
end

def fetch_cdn(url)
url = @config[url] || url
Pathname.new(url)
end
end
end
1 change: 0 additions & 1 deletion lib/language_pack/helpers/bundler_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,4 @@ def parse_gemfile_lock
gemfile_contents = File.read(@gemfile_lock_path)
Bundler::LockfileParser.new(gemfile_contents)
end

end
10 changes: 5 additions & 5 deletions lib/language_pack/helpers/download_presence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
class LanguagePack::Helpers::DownloadPresence
STACKS = ['heroku-20', 'heroku-22']

def initialize(path, stacks: STACKS)
@path = path
def initialize(file_name:, stacks: STACKS)
@file_name = file_name
@stacks = stacks
@fetchers = []
@threads = []
@stacks.each do |stack|
@fetchers << LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack)
@fetchers << LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: stack)
end
end

Expand All @@ -43,7 +43,7 @@ def exists_on_next_stack?(current_stack: )
return false unless supported_stack?(current_stack: current_stack)

next_index = @stacks.index(current_stack) + 1
@threads[next_index]
@threads[next_index].value
end

def valid_stack_list
Expand All @@ -67,7 +67,7 @@ def does_not_exist?
def call
@fetchers.map do |fetcher|
@threads << Thread.new do
fetcher.exists?(@path, 3)
fetcher.exists?(@file_name, 3)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/language_pack/helpers/outdated_ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ruby_version = LanguagePack::RubyVersion.new("ruby-2.2.5")
# outdated = LanguagePack::Helpers::OutdatedRubyVersion.new(
# current_ruby_version: ruby_version,
# fetcher: LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, "heroku-20")
# fetcher: LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL, stack: "heroku-22")
# )
#
# outdated.call
Expand All @@ -34,7 +34,6 @@ def initialize(current_ruby_version: , fetcher:)

def can_check?
return false if current_ruby_version.patchlevel_is_significant?
return false if current_ruby_version.rbx?
return false if current_ruby_version.jruby?

true
Expand Down
51 changes: 41 additions & 10 deletions lib/language_pack/installers/heroku_ruby_installer.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
require 'language_pack/installers/ruby_installer'
require 'language_pack/base'
require 'language_pack/shell_helpers'

class LanguagePack::Installers::HerokuRubyInstaller
include LanguagePack::ShellHelpers, LanguagePack::Installers::RubyInstaller
module LanguagePack::Installers; end

class LanguagePack::Installers::HerokuRubyInstaller
BASE_URL = LanguagePack::Base::VENDOR_URL
BIN_DIR = Pathname("bin")

include LanguagePack::ShellHelpers
attr_reader :fetcher

def initialize(stack)
@fetcher = LanguagePack::Fetcher.new(BASE_URL, stack)
def initialize(stack:)
@fetcher = LanguagePack::Fetcher.new(BASE_URL, stack: stack)
end

def fetch_unpack(ruby_version, install_dir, build = false)
def install(ruby_version, install_dir)
fetch_unpack(ruby_version, install_dir)
setup_binstubs(install_dir)
end

def fetch_unpack(ruby_version, install_dir)
FileUtils.mkdir_p(install_dir)
Dir.chdir(install_dir) do
file = "#{ruby_version.version_for_download}.tgz"
if build
file.sub!("ruby", "ruby-build")
@fetcher.fetch_untar("#{ruby_version.version_for_download}.tgz")
end
end

private def setup_binstubs(install_dir)
BIN_DIR.mkpath
run("ln -s ruby #{install_dir}/bin/ruby.exe")

install_pathname = Pathname.new(install_dir)
Dir["#{install_dir}/bin/*"].each do |vendor_bin|
# for Ruby 2.6.0+ don't symlink the Bundler bin so our shim works
next if vendor_bin.include?("bundle")

# The bin/rake binstub generated when compiling ruby does not load bundler
# which can cause unexpected failures. Deleting this binstub allows two things:
#
# - If the app includes a custom binstub allows it to be used
# - If the app does not include a custom binstub, then it will fall back to vendor/bundle/bin/rake
# which is generated by bundler
#
# Discussion: https://github.com/heroku/heroku-buildpack-ruby/issues/1025#issuecomment-653102430
next if vendor_bin.include?("rake")

if install_pathname.absolute?
run("ln -s #{vendor_bin} #{BIN_DIR}")
else
run("ln -s ../#{vendor_bin} #{BIN_DIR}")
end
@fetcher.fetch_untar(file)
end
end
end
Expand Down
20 changes: 0 additions & 20 deletions lib/language_pack/installers/rbx_installer.rb

This file was deleted.

53 changes: 0 additions & 53 deletions lib/language_pack/installers/ruby_installer.rb

This file was deleted.

Loading

0 comments on commit fc3d81f

Please sign in to comment.