Skip to content

Commit

Permalink
Default ruby to only currently supported version (3.2.0) (vercel#11104)
Browse files Browse the repository at this point in the history
We're currently using the directory name at `./vendor/bundle/ruby/`[0]
to determine ruby version. This directory is created as part of running
`bundle install` during the build process. However, when multiple ruby
versions are available, you can end up with multiple directories and the
0th entry at `./vendor/bundle/ruby/` isn't guaranteed to be the Ruby
version specified in the project.

Other companies in this space seem to do some order of 
 - check for value in `.ruby-version` file
 - check for value passed into `ruby` directive in the Gemfile
- check the value in the `*.gemspec` file if the Gemfile has a `gemspec`
directive.

We'll do that work in a future PR but for _now_ our only supported Ruby
version is Ruby 3.2.x [as of
2023-11-22](https://vercel.com/changelog/upgrading-ruby-v2-7-to-v3-2).
So this can be hard-coded for the moment.

Skipping ruby tests now since these target _current_ prod where Ruby
3.2.x is not in `PATH` until we redeploy after this gets deployed.
  • Loading branch information
trek authored Jan 30, 2024
1 parent 4d1ab42 commit de63e35
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-rats-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vercel/static-build": minor
---

Default ruby to only currently supported version (3.2.0)
2 changes: 2 additions & 0 deletions packages/build-utils/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const skipFixtures: string[] = [
'23-pnpm-workspaces',
'41-nx-monorepo',
'42-npm-workspace-with-nx',
'jekyll-v4',
'middleman-v4',
];

// eslint-disable-next-line no-restricted-syntax
Expand Down
8 changes: 3 additions & 5 deletions packages/static-build/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
LocalFileSystemDetector,
} from '@vercel/fs-detectors';

const SUPPORTED_RUBY_VERSION = '3.2.0';
const sleep = (n: number) => new Promise(resolve => setTimeout(resolve, n));

const DEV_SERVER_PORT_BIND_TIMEOUT = ms('5m');
Expand Down Expand Up @@ -541,12 +542,9 @@ export const build: BuildV2 = async ({
pathList.push(vendorBin); // Add `./vendor/bin`
debug(`Added "${vendorBin}" to PATH env because a Gemfile was found`);
const dir = path.join(workPath, 'vendor', 'bundle', 'ruby');
const rubyVersion =
existsSync(dir) && statSync(dir).isDirectory()
? readdirSync(dir)[0]
: '';
const rubyVersion = SUPPORTED_RUBY_VERSION;
if (rubyVersion) {
gemHome = path.join(dir, rubyVersion); // Add `./vendor/bundle/ruby/2.7.0`
gemHome = path.join(dir, rubyVersion);
debug(`Set GEM_HOME="${gemHome}" because a Gemfile was found`);
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/static-build/test/integration-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ module.exports = function setupTests(groupIndex) {
console.log('testing group', groupIndex, fixtures);
}

const fixturesToSkip = ['jekyll-v3', 'jekyll-v4', 'middleman-v4'];

// eslint-disable-next-line no-restricted-syntax
for (const fixture of fixtures) {
if (fixturesToSkip.includes(fixture)) {
continue;
}

const errMsg = testsThatFailToBuild.get(fixture);
if (errMsg) {
// eslint-disable-next-line no-loop-func
Expand Down

0 comments on commit de63e35

Please sign in to comment.