diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0b9a9716..034e48dc7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,19 +96,33 @@ jobs: - run: bundle exec rake --version - run: bundle exec rake + # Ensure the same bundle commands work in bash on Windows + - name: bundle install (bash) + run: bundle install + shell: bash + if: startsWith(matrix.os, 'windows') + - name: bundle exec rake --version (bash) + run: bundle exec rake --version + shell: bash + if: startsWith(matrix.os, 'windows') + - name: bundle exec rake (bash) + run: bundle exec rake + shell: bash + if: startsWith(matrix.os, 'windows') + - name: Test `gem github:` in a Gemfile run: bundle install env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/gem_from_github.gemfile - - name: which ruby, rake + - name: which ruby, rake bundle if: "!startsWith(matrix.os, 'windows')" - run: which -a ruby rake - - name: where ruby, rake + run: which -a ruby rake bundle + - name: where ruby, rake, bundle if: startsWith(matrix.os, 'windows') run: | $ErrorActionPreference = 'Continue' - $where = 'ruby', 'rake' + $where = 'ruby', 'rake', 'bundle' foreach ($e in $where) { $rslt = where.exe $e 2>&1 | Out-String if ($rslt.contains($e)) { echo $rslt.Trim() } @@ -117,7 +131,7 @@ jobs: } - name: bash test shell: bash - run: echo ~ && which -a bundle + run: echo ~ && bundle install - name: Windows JRuby if: startsWith(matrix.os, 'windows') && startsWith(matrix.ruby, 'jruby') run: gem install sassc diff --git a/bundler.js b/bundler.js index 71e8f25bf..df27a009d 100644 --- a/bundler.js +++ b/bundler.js @@ -72,8 +72,14 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock if (bundlerVersion === 'default') { if (common.isBundler2dot2Default(engine, rubyVersion)) { - console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) - return '2' + if (common.windows && engine === 'ruby') { + // https://github.com/ruby/setup-ruby/issues/371 + console.log(`Installing latest Bundler for ${engine}-${rubyVersion} on Windows because bin/bundle does not work in bash otherwise`) + bundlerVersion = 'latest' + } else { + console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) + return '2' + } } else if (common.hasBundlerDefaultGem(engine, rubyVersion)) { // Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`: // https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304 diff --git a/dist/index.js b/dist/index.js index 087296f7c..a0f8eeaae 100644 --- a/dist/index.js +++ b/dist/index.js @@ -86,8 +86,14 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p if (bundlerVersion === 'default') { if (common.isBundler2dot2Default(engine, rubyVersion)) { - console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) - return '2' + if (common.windows && engine === 'ruby') { + // https://github.com/ruby/setup-ruby/issues/371 + console.log(`Installing latest Bundler for ${engine}-${rubyVersion} on Windows because bin/bundle does not work in bash otherwise`) + bundlerVersion = 'latest' + } else { + console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) + return '2' + } } else if (common.hasBundlerDefaultGem(engine, rubyVersion)) { // Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`: // https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304