fix: use workspace-local mise dir on Windows for cache compatibility

@actions/cache uses @actions/glob internally to resolve cache paths,
which fails when the path is on a different drive than GITHUB_WORKSPACE.
On Windows CI runners, GITHUB_WORKSPACE is typically on D: while
LOCALAPPDATA (the previous default) is on C:, causing saveCache to
throw "Path Validation Error" on cold caches.

Default to GITHUB_WORKSPACE/.mise on Windows so the cache path is
always on the same drive as the workspace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jdx 2026-04-11 14:22:01 +00:00
parent ac93c8a0e0
commit b8f8b694da
No known key found for this signature in database
GPG key ID: 584DADE86724B407
5 changed files with 20 additions and 25 deletions

View file

@ -47,6 +47,7 @@ jobs:
- name: Setup mise
uses: ./
with:
cache_key_prefix: mise-debug-v1
mise_toml: |
[tools]
jq = "1.7.1"
@ -55,6 +56,7 @@ jobs:
MY_ENV_VAR = "abc"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
- run: mise --version
- run: mise x jq -- jq --version
- run: which jq

8
dist/index.js generated vendored
View file

@ -81447,6 +81447,14 @@ function miseDir() {
async function saveCache(cacheKey) {
await core.group(`Saving mise cache`, async () => {
const cachePath = miseDir();
core.info(`Cache path: ${cachePath}`);
core.info(`Cache path exists: ${fs.existsSync(cachePath)}`);
core.info(`Platform: ${process.platform}`);
core.info(`GITHUB_WORKSPACE: ${process.env.GITHUB_WORKSPACE}`);
if (fs.existsSync(cachePath)) {
const contents = await fs.promises.readdir(cachePath);
core.info(`Cache dir contents: ${JSON.stringify(contents)}`);
}
if (!fs.existsSync(cachePath)) {
throw new Error(`Cache folder path does not exist on disk: ${cachePath}`);
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

24
package-lock.json generated
View file

@ -2405,9 +2405,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2422,9 +2419,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@ -2439,9 +2433,6 @@
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2456,9 +2447,6 @@
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2473,9 +2461,6 @@
"riscv64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@ -2490,9 +2475,6 @@
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2507,9 +2489,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@ -2524,9 +2503,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [

View file

@ -399,6 +399,7 @@ function miseDir(): string {
const { MISE_DATA_DIR, XDG_DATA_HOME, LOCALAPPDATA } = process.env
if (MISE_DATA_DIR) return MISE_DATA_DIR
if (XDG_DATA_HOME) return path.join(XDG_DATA_HOME, 'mise')
if (process.platform === 'win32' && LOCALAPPDATA)
return path.join(LOCALAPPDATA, 'mise')
@ -408,6 +409,14 @@ function miseDir(): string {
async function saveCache(cacheKey: string): Promise<void> {
await core.group(`Saving mise cache`, async () => {
const cachePath = miseDir()
core.info(`Cache path: ${cachePath}`)
core.info(`Cache path exists: ${fs.existsSync(cachePath)}`)
core.info(`Platform: ${process.platform}`)
core.info(`GITHUB_WORKSPACE: ${process.env.GITHUB_WORKSPACE}`)
if (fs.existsSync(cachePath)) {
const contents = await fs.promises.readdir(cachePath)
core.info(`Cache dir contents: ${JSON.stringify(contents)}`)
}
if (!fs.existsSync(cachePath)) {
throw new Error(`Cache folder path does not exist on disk: ${cachePath}`)