Skip to content

Commit 87ccb75

Browse files
committed
Workaround the CRuby bug of bin/bundle in bash on Windows
* Fixes #371 * See https://bugs.ruby-lang.org/issues/18970
1 parent 19b31c7 commit 87ccb75

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,33 @@ jobs:
9696
- run: bundle exec rake --version
9797
- run: bundle exec rake
9898

99+
# Ensure the same bundle commands work in bash on Windows
100+
- name: bundle install (bash)
101+
run: bundle install
102+
shell: bash
103+
if: startsWith(matrix.os, 'windows')
104+
- name: bundle exec rake --version (bash)
105+
run: bundle exec rake --version
106+
shell: bash
107+
if: startsWith(matrix.os, 'windows')
108+
- name: bundle exec rake (bash)
109+
run: bundle exec rake
110+
shell: bash
111+
if: startsWith(matrix.os, 'windows')
112+
99113
- name: Test `gem github:` in a Gemfile
100114
run: bundle install
101115
env:
102116
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/gem_from_github.gemfile
103117

104-
- name: which ruby, rake
118+
- name: which ruby, rake bundle
105119
if: "!startsWith(matrix.os, 'windows')"
106-
run: which -a ruby rake
107-
- name: where ruby, rake
120+
run: which -a ruby rake bundle
121+
- name: where ruby, rake, bundle
108122
if: startsWith(matrix.os, 'windows')
109123
run: |
110124
$ErrorActionPreference = 'Continue'
111-
$where = 'ruby', 'rake'
125+
$where = 'ruby', 'rake', 'bundle'
112126
foreach ($e in $where) {
113127
$rslt = where.exe $e 2>&1 | Out-String
114128
if ($rslt.contains($e)) { echo $rslt.Trim() }
@@ -117,7 +131,7 @@ jobs:
117131
}
118132
- name: bash test
119133
shell: bash
120-
run: echo ~ && which -a bundle
134+
run: echo ~ && bundle install
121135
- name: Windows JRuby
122136
if: startsWith(matrix.os, 'windows') && startsWith(matrix.ruby, 'jruby')
123137
run: gem install sassc

bundler.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
7272

7373
if (bundlerVersion === 'default') {
7474
if (common.isBundler2dot2Default(engine, rubyVersion)) {
75-
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
76-
return '2'
75+
if (common.windows && engine === 'ruby') {
76+
// https://github.com/ruby/setup-ruby/issues/371
77+
console.log(`Installing latest Bundler for ${engine}-${rubyVersion} on Windows because bin/bundle does not work in bash otherwise`)
78+
bundlerVersion = 'latest'
79+
} else {
80+
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
81+
return '2'
82+
}
7783
} else if (common.hasBundlerDefaultGem(engine, rubyVersion)) {
7884
// Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`:
7985
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304

dist/index.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)