Skip to content

Commit 30011b6

Browse files
committed
Cleanup PATH for JRuby on Windows
* That way we remove the default Ruby in PATH which was confusing.
1 parent f422c05 commit 30011b6

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
ruby-version: ${{ matrix.ruby }}
3535
- run: ruby --version
3636
- run: ridk version
37-
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
37+
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
3838
- name: Subprocess test
3939
run: ruby test_subprocess.rb
4040
- name: OpenSSL version

dist/index.js

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

ruby-builder.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ export function getAvailableVersions(platform, engine) {
1616
export async function install(platform, ruby) {
1717
const rubyPrefix = await downloadAndExtract(platform, ruby)
1818

19-
core.addPath(path.join(rubyPrefix, 'bin'))
20-
if (ruby.startsWith('rubinius')) {
21-
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
19+
if (platform === 'windows-latest') {
20+
require('./windows').setupPath(undefined, rubyPrefix)
21+
} else {
22+
core.addPath(path.join(rubyPrefix, 'bin'))
23+
if (ruby.startsWith('rubinius')) {
24+
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
25+
}
2226
}
2327

2428
return rubyPrefix

windows.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ export async function install(platform, ruby) {
3333
const rubyPrefix = `${drive}:\\${base}`
3434

3535
const [hostedRuby, msys2] = await linkMSYS2()
36-
const newPath = setupPath(msys2, rubyPrefix)
37-
core.exportVariable('PATH', newPath)
36+
setupPath(msys2, rubyPrefix)
3837

3938
if (version.startsWith('2.2') || version.startsWith('2.3')) {
4039
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
@@ -62,7 +61,7 @@ async function linkMSYS2() {
6261
return [latestHostedRuby, msys2]
6362
}
6463

65-
function setupPath(msys2, rubyPrefix) {
64+
export function setupPath(msys2, rubyPrefix) {
6665
let path = process.env['PATH'].split(';')
6766

6867
// Remove conflicting dev tools from PATH
@@ -71,11 +70,14 @@ function setupPath(msys2, rubyPrefix) {
7170
// Remove default Ruby in PATH
7271
path = path.filter(e => !e.match(/\bRuby\b/))
7372

74-
// Add MSYS2 in PATH
75-
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
73+
if (msys2) {
74+
// Add MSYS2 in PATH
75+
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
76+
}
7677

7778
// Add the downloaded Ruby in PATH
7879
path.unshift(`${rubyPrefix}\\bin`)
7980

80-
return path.join(';')
81+
const newPath = path.join(';')
82+
core.exportVariable('PATH', newPath)
8183
}

0 commit comments

Comments
 (0)