Skip to content

Commit

Permalink
Workaround the CRuby bug of bin/bundle in bash on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Aug 20, 2022
1 parent a1396b7 commit cedd733
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand All @@ -117,7 +131,7 @@ jobs:
}
- name: bash test
shell: bash
run: echo ~
run: echo ~ && which -a bundle
- name: Windows JRuby
if: startsWith(matrix.os, 'windows') && startsWith(matrix.ruby, 'jruby')
run: gem install sassc
Expand Down
10 changes: 8 additions & 2 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cedd733

Please sign in to comment.