heroku / buildpacks-ruby

Heroku's Cloud Native Buildpack for Ruby applications.
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Warn users about using default Ruby version when `Gemfile.lock` does not specify the version #304

Open lilacstella opened 3 months ago

lilacstella commented 3 months ago

The current buildpack does not warn users when the Gemfile.lock lacks a specified Ruby version. This can cause applications to run on a default Ruby version, potentially leading to unexpected behavior or errors. This feature was part of the classic Ruby buildpack but has not been implemented here yet. This warning should inform users that the buildpack will use a default Ruby version and recommend specifying a Ruby version in their Gemfile.lock to ensure consistent and predictable application behavior.

Actual result

[Checking Node.js version]
Node.js version not specified, using 20.x
Resolved Node.js version: 20.15.1

[Installing Node.js distribution]
Downloading Node.js 20.15.1 (linux-amd64) from https://nodejs.org/download/release/v20.15.1/node-v20.15.1-linux-x64.tar.gz
Verifying checksum
Extracting Node.js 20.15.1 (linux-amd64)
Installing Node.js 20.15.1 (linux-amd64)

# Heroku Ruby Buildpack

- Metrics agent
  - Skipping install (`barnes` gem not found)
- Ruby version `3.3.1` from `Gemfile.lock`
  - Installing ........................................... (40.548s)
- Bundler version `2.3.16` from `Gemfile.lock`
  - Running `gem install bundler --version 2.3.16` .... (1.808s)
- Bundle install
  - Running `BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`

      Fetching gem metadata from https://rubygems.org/.........

Expected outcome

When the Gemfile.lock does not specify a Ruby version, the buildpack should:

The warning could look something like this:

To avoid unexpected results due to difference in Ruby versions, please specify a version in your `Gemfile.lock` by choosing the version in the `Gemfile` and using `bundle install` to update the `Gemfile.lock`.
https://devcenter.heroku.com/articles/ruby-versions