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

Expose GHCup binary location as action output #81

Open
fendor opened this issue May 9, 2024 · 3 comments · May be fixed by #82
Open

Expose GHCup binary location as action output #81

fendor opened this issue May 9, 2024 · 3 comments · May be fixed by #82
Labels
ghcup Concerning GHCup outputs Concerning outputs of the action platform: macOS

Comments

@fendor
Copy link

fendor commented May 9, 2024

vscode-haskell needs direct access to ghcup to run its test successfully. Until recently, ghcup was always on $PATH and we could simply run ghcup install ... and install all the binaries that we needed. Additionally, the tests themselves also call ghcup install.

However, this seems to have changed recently for macos-latest: https://github.com/haskell/vscode-haskell/actions/runs/9015398738/job/24769933756?pr=1077

It looks like ghcup is not on the $PATH any more, but hidden somewhere in the hostedtoolcache.

One way to work around this for good, is to provide the path to ghcup as an action output, then we don't have to rely on ghcup to be on the $PATH, and can find it reliably.

@fendor
Copy link
Author

fendor commented May 9, 2024

I see this seems to have been discussed at actions/runner-images#9242

@andreasabel
Copy link
Member

@fendor wrote:

One way to work around this for good, is to provide the path to ghcup as an action output,

The logic to find ghcup is currently this one:

setup/src/installer.ts

Lines 334 to 353 in 64f55f9

async function ghcupBin(os: OS, arch: Arch): Promise<string> {
core.debug(`ghcupBin : ${os}`);
if (os === 'win32') {
return 'ghcup';
}
const cachedBin = tc.find('ghcup', ghcup_version);
if (cachedBin) return join(cachedBin, 'ghcup');
const binArch = await stackArchString(arch);
const bin = await tc.downloadTool(
`https://downloads.haskell.org/ghcup/${ghcup_version}/${binArch}-${
os === 'darwin' ? 'apple-darwin' : 'linux'
}-ghcup-${ghcup_version}`
);
await afs.chmod(bin, 0o755);
return join(
await tc.cacheFile(bin, 'ghcup', 'ghcup', ghcup_version),
'ghcup'
);
}

It would be easy to export the string to invoke GHCup from this. Note however that it is not always the path to ghcup, e.g. for windows it will just be ghcup.
So the output could be named ghcup-command, for instance.
I do not know if this is sufficient for your purposes, please let me know.
It would be nicer to always return the path to ghcup, maybe as output ghcup-binary (to be bikeshedded), but this would require some more work (which I personally would not invest at this point).

I'd be happy to accept a PR with mild changes to the code base. (My main concern is backward compatibility.)

@andreasabel andreasabel added platform: macOS outputs Concerning outputs of the action ghcup Concerning GHCup labels May 10, 2024
@fendor
Copy link
Author

fendor commented May 10, 2024

Your suggestion seems reasonable to me, and I think it would fix my issues nicely.

@fendor fendor linked a pull request May 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ghcup Concerning GHCup outputs Concerning outputs of the action platform: macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants