From 57d46d78b7d959dc4a248024a29bb17d4e357e5c Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 7 Aug 2021 19:36:01 +0200 Subject: [PATCH] Installing libxml2-dev libxslt-dev is only needed on TruffleRuby < 21.1 * TruffleRuby >= 21.1 installs nokogiri with the packaged libxml2/libxslt like on CRuby by default. See https://github.com/oracle/truffleruby/issues/62 --- bundler.js | 10 +++++----- dist/index.js | 14 +++++++------- index.js | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bundler.js b/bundler.js index 260e6e8..3d76046 100644 --- a/bundler.js +++ b/bundler.js @@ -40,12 +40,12 @@ function readBundledWithFromGemfileLock(lockFile) { return null } -async function afterLockFile(lockFile, platform, engine) { - if (engine.startsWith('truffleruby') && platform.startsWith('ubuntu-')) { +async function afterLockFile(lockFile, platform, engine, rubyVersion) { + if (engine.startsWith('truffleruby') && common.floatVersion(rubyVersion) < 21.1 && platform.startsWith('ubuntu-')) { const contents = fs.readFileSync(lockFile, 'utf8') if (contents.includes('nokogiri')) { - await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby', async () => - exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) + await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby < 21.1', async () => + exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) } } } @@ -126,7 +126,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer await exec.exec('bundle', ['lock'], envOptions) } - await afterLockFile(lockFile, platform, engine) + await afterLockFile(lockFile, platform, engine, rubyVersion) // cache key const paths = [cachePath] diff --git a/dist/index.js b/dist/index.js index 88212b9..1477c37 100644 --- a/dist/index.js +++ b/dist/index.js @@ -54,12 +54,12 @@ function readBundledWithFromGemfileLock(lockFile) { return null } -async function afterLockFile(lockFile, platform, engine) { - if (engine.startsWith('truffleruby') && platform.startsWith('ubuntu-')) { +async function afterLockFile(lockFile, platform, engine, rubyVersion) { + if (engine.startsWith('truffleruby') && common.floatVersion(rubyVersion) < 21.1 && platform.startsWith('ubuntu-')) { const contents = fs.readFileSync(lockFile, 'utf8') if (contents.includes('nokogiri')) { - await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby', async () => - exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) + await common.measure('Installing libxml2-dev libxslt-dev, required to install nokogiri on TruffleRuby < 21.1', async () => + exec.exec('sudo', ['apt-get', '-yqq', 'install', 'libxml2-dev', 'libxslt-dev'], { silent: true })) } } } @@ -140,7 +140,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b await exec.exec('bundle', ['lock'], envOptions) } - await afterLockFile(lockFile, platform, engine) + await afterLockFile(lockFile, platform, engine, rubyVersion) // cache key const paths = [cachePath] @@ -59472,11 +59472,11 @@ async function setupRuby(options = {}) { const [gemfile, lockFile] = bundler.detectGemfiles() const bundlerVersion = await common.measure('Installing Bundler', async () => - bundler.installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version)) + bundler.installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version)) if (inputs['bundler-cache'] === 'true') { await common.measure('bundle install', async () => - bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) + bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) } } diff --git a/index.js b/index.js index 648b80d..a66e0fc 100644 --- a/index.js +++ b/index.js @@ -64,11 +64,11 @@ export async function setupRuby(options = {}) { const [gemfile, lockFile] = bundler.detectGemfiles() const bundlerVersion = await common.measure('Installing Bundler', async () => - bundler.installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version)) + bundler.installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version)) if (inputs['bundler-cache'] === 'true') { await common.measure('bundle install', async () => - bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) + bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) } }