Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Fix #210: set store-dir in .cabal/config to dodge cabal 3.10 XDG
Browse files Browse the repository at this point in the history
We set the `store-dir` (`outputs.cabal-store`) explicitly in the cabal configuration file
because cabal 3.10 has some context-dependent default for it:
If `~/.cabal` is not present, it uses the new XDG layout, otherwise not.
  • Loading branch information
andreasabel committed Mar 16, 2023
1 parent 86bd3ed commit dbe6810
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
15 changes: 8 additions & 7 deletions setup/dist/index.js

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

15 changes: 8 additions & 7 deletions setup/lib/setup-haskell.js

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

17 changes: 11 additions & 6 deletions setup/src/setup-haskell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ export default async function run(
silent: true,
ignoreReturnCode: true
});

// Set the 'store-dir' in the cabal configuration.
// Blindly appending is fine.
// Cabal merges these and picks the last defined option.
const configFile = await cabalConfig();
if (process.platform === 'win32') {
fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`);
core.setOutput('cabal-store', 'C:\\sr');
} else {
core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`);
// Issue #130: for non-choco installs, add ~/.cabal/bin to PATH
const storeDir =
process.platform === 'win32'
? 'C:\\sr'
: `${process.env.HOME}/.cabal/store`;
fs.appendFileSync(configFile, `store-dir: ${storeDir}${EOL}`);
core.setOutput('cabal-store', storeDir);

// Issue #130: for non-choco installs, add ~/.cabal/bin to PATH
if (process.platform !== 'win32') {
const installdir = `${process.env.HOME}/.cabal/bin`;
core.info(`Adding ${installdir} to PATH`);
core.addPath(installdir);
Expand Down

0 comments on commit dbe6810

Please sign in to comment.