Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PATH on Windows #20

Merged
merged 4 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Test this action
on:
push:
branches-ignore:
- master
- v1
tags-ignore:
- '*'
Expand Down
15 changes: 10 additions & 5 deletions dist/index.js

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

15 changes: 10 additions & 5 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function install(platform, ruby) {
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]

const downloadPath = await tc.downloadTool(url)
await exec.exec(`7z x ${downloadPath} -xr!${base}\\share\\doc -o${drive}:\\`)
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
const rubyPrefix = `${drive}:\\${base}`

const [hostedRuby, msys2] = await linkMSYS2()
Expand Down Expand Up @@ -62,10 +62,8 @@ async function linkMSYS2() {
}

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

// Remove conflicting dev tools from PATH
path = path.filter(e => !e.match(/\b(Chocolatey|CMake|mingw64|OpenSSL|Strawberry)\b/))
const originalPath = process.env['PATH'].split(';')
let path = originalPath.slice()

// Remove default Ruby in PATH
path = path.filter(e => !e.match(/\bRuby\b/))
Expand All @@ -78,6 +76,13 @@ export function setupPath(msys2, rubyPrefix) {
// Add the downloaded Ruby in PATH
path.unshift(`${rubyPrefix}\\bin`)

console.log("Entries removed from PATH to avoid conflicts with Ruby:")
for (const entry of originalPath) {
if (!path.includes(entry)) {
console.log(entry)
}
}

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