Skip to content

Commit ce6a88f

Browse files
committed
fix cygwin root logic
1 parent 753701b commit ce6a88f

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

dist/index.cjs

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

dist/post/index.cjs

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

packages/setup-ocaml/src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ export const OPAM_ROOT = (() => {
9797
return path.join(os.homedir(), ".opam");
9898
})();
9999

100+
// opam's internal Cygwin installation paths (only used on Windows)
101+
export const CYGWIN_ROOT = path.join(OPAM_ROOT, ".cygwin", "root");
102+
103+
export const CYGWIN_ROOT_BIN = path.join(CYGWIN_ROOT, "bin");
104+
100105
export const RUNNER_ENVIRONMENT = ((): "github-hosted" | "self-hosted" => {
101106
const ImageOS = process.env.ImageOS;
102107
const RUNNER_ENVIRONMENT = process.env.RUNNER_ENVIRONMENT as

packages/setup-ocaml/src/installer.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import * as os from "node:os";
33
import * as path from "node:path";
44
import * as process from "node:process";
55
import * as core from "@actions/core";
6-
import { exec, getExecOutput } from "@actions/exec";
6+
import { exec } from "@actions/exec";
77
import { restoreDuneCache, restoreOpamCaches, saveOpamCache } from "./cache.js";
88
import {
9+
CYGWIN_ROOT,
10+
CYGWIN_ROOT_BIN,
911
DUNE_CACHE,
1012
DUNE_CACHE_ROOT,
1113
OPAM_PIN,
@@ -26,17 +28,6 @@ import {
2628
import { retrieveOpamLocalPackages } from "./packages.js";
2729
import { resolvedCompiler } from "./version.js";
2830

29-
async function getCygwinRoot(): Promise<string> {
30-
const { stdout } = await getExecOutput("opam", [
31-
"exec",
32-
"--",
33-
"cygpath",
34-
"-w",
35-
"/",
36-
]);
37-
return stdout.trim();
38-
}
39-
4031
export async function installer() {
4132
if (core.isDebug()) {
4233
core.exportVariable("OPAMVERBOSE", 1);
@@ -71,12 +62,10 @@ export async function installer() {
7162
const { opamCacheHit } = await restoreOpamCaches();
7263
await setupOpam();
7364
if (PLATFORM === "windows") {
74-
const cygwinRoot = await getCygwinRoot();
75-
const bashEnvPath = path.join(cygwinRoot, "bash_env");
65+
const bashEnvPath = path.join(CYGWIN_ROOT, "bash_env");
7666
await fs.writeFile(bashEnvPath, "set -o igncr");
7767
core.exportVariable("BASH_ENV", bashEnvPath);
78-
const cygwinRootBin = path.join(cygwinRoot, "bin");
79-
core.addPath(cygwinRootBin);
68+
core.addPath(CYGWIN_ROOT_BIN);
8069
}
8170
await repositoryRemoveAll();
8271
await repositoryAddAll(OPAM_REPOSITORIES);

0 commit comments

Comments
 (0)