mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-02 09:13:19 +08:00
Don't set the MSYS env var globally (#1329)
b2d865f180 introduced a call to exportVariable() to export the MSYS env
var, which configures the symlink strategy for MSYS2/cygwin binaries it calls.
By setting the env var globally, this also changes the behaviour of other MSYS2
using tools in a CI job, and also overrides MSYS configuration set by the user,
which I think was not intended.
To avoid this leakage set the MSYS env var only for the commands which
@actions/cache calls.
Fixes #1312
This commit is contained in:
7
packages/cache/src/internal/tar.ts
vendored
7
packages/cache/src/internal/tar.ts
vendored
@@ -1,5 +1,4 @@
|
||||
import {exec} from '@actions/exec'
|
||||
import {exportVariable} from '@actions/core'
|
||||
import * as io from '@actions/io'
|
||||
import {existsSync, writeFileSync} from 'fs'
|
||||
import * as path from 'path'
|
||||
@@ -14,7 +13,6 @@ import {
|
||||
} from './constants'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
exportVariable('MSYS', 'winsymlinks:nativestrict')
|
||||
|
||||
// Returns tar path and type: BSD or GNU
|
||||
async function getTarPath(): Promise<ArchiveTool> {
|
||||
@@ -250,7 +248,10 @@ async function getCompressionProgram(
|
||||
async function execCommands(commands: string[], cwd?: string): Promise<void> {
|
||||
for (const command of commands) {
|
||||
try {
|
||||
await exec(command, undefined, {cwd})
|
||||
await exec(command, undefined, {
|
||||
cwd,
|
||||
env: {...(process.env as object), MSYS: 'winsymlinks:nativestrict'}
|
||||
})
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`${command.split(' ')[0]} failed with error: ${error?.message}`
|
||||
|
||||
Reference in New Issue
Block a user