Skip to content

Commit

Permalink
Cleanup PATH for JRuby on Windows
Browse files Browse the repository at this point in the history
* That way we remove the default Ruby in PATH which was confusing.
  • Loading branch information
eregon committed Feb 8, 2020
1 parent f422c05 commit 30011b6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
ruby-version: ${{ matrix.ruby }}
- run: ruby --version
- run: ridk version
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, 'jruby') && !startsWith(matrix.ruby, '2.3') && !startsWith(matrix.ruby, '2.2')
- name: Subprocess test
run: ruby test_subprocess.rb
- name: OpenSSL version
Expand Down
23 changes: 15 additions & 8 deletions dist/index.js

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

10 changes: 7 additions & 3 deletions ruby-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ export function getAvailableVersions(platform, engine) {
export async function install(platform, ruby) {
const rubyPrefix = await downloadAndExtract(platform, ruby)

core.addPath(path.join(rubyPrefix, 'bin'))
if (ruby.startsWith('rubinius')) {
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
if (platform === 'windows-latest') {
require('./windows').setupPath(undefined, rubyPrefix)
} else {
core.addPath(path.join(rubyPrefix, 'bin'))
if (ruby.startsWith('rubinius')) {
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
}
}

return rubyPrefix
Expand Down
14 changes: 8 additions & 6 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export async function install(platform, ruby) {
const rubyPrefix = `${drive}:\\${base}`

const [hostedRuby, msys2] = await linkMSYS2()
const newPath = setupPath(msys2, rubyPrefix)
core.exportVariable('PATH', newPath)
setupPath(msys2, rubyPrefix)

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

function setupPath(msys2, rubyPrefix) {
export function setupPath(msys2, rubyPrefix) {
let path = process.env['PATH'].split(';')

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

// Add MSYS2 in PATH
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
if (msys2) {
// Add MSYS2 in PATH
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
}

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

return path.join(';')
const newPath = path.join(';')
core.exportVariable('PATH', newPath)
}

0 comments on commit 30011b6

Please sign in to comment.