From dbe681042121eae30665856f2b36672b65c37680 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 16 Mar 2023 08:59:54 +0100 Subject: [PATCH] Fix #210: set `store-dir` in `.cabal/config` to dodge cabal 3.10 XDG 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. --- setup/dist/index.js | 15 ++++++++------- setup/lib/setup-haskell.js | 15 ++++++++------- setup/src/setup-haskell.ts | 17 +++++++++++------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/setup/dist/index.js b/setup/dist/index.js index d3cebbc4..16908de5 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -13871,16 +13871,17 @@ async function run(inputs) { 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${os_1.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}${os_1.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); diff --git a/setup/lib/setup-haskell.js b/setup/lib/setup-haskell.js index 0c831268..3332ad0d 100644 --- a/setup/lib/setup-haskell.js +++ b/setup/lib/setup-haskell.js @@ -64,16 +64,17 @@ async function run(inputs) { 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${os_1.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}${os_1.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); diff --git a/setup/src/setup-haskell.ts b/setup/src/setup-haskell.ts index 4b183d94..e9104fe9 100644 --- a/setup/src/setup-haskell.ts +++ b/setup/src/setup-haskell.ts @@ -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);