Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Nov 20, 2025

Summary

  • Fix ReferenceError where __dirname is not defined in ES modules
  • Add ES module-compatible __dirname calculation using import.meta.url
  • Update generated mise.ts file from render task

Problem

The autofix CI job was failing in PR #7010 with:

ReferenceError: __dirname is not defined
    at main (/home/runner/work/mise/mise/xtasks/fig/addCustomGenerators.ts:150:40)

This occurred because addCustomGenerators.ts is an ES module (imported with import), but was using __dirname which is only available in CommonJS modules.

Solution

Import fileURLToPath from node:url and calculate __dirname from import.meta.url:

import { fileURLToPath } from "node:url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

This provides ES module-compatible access to the current directory path.

Test Plan

  • Run mise run render to verify the fig generation works
  • Run mise run lint-fix to ensure all linting passes
  • Verify pre-commit hooks pass

Changes

  • xtasks/fig/addCustomGenerators.ts: Add ES module-compatible __dirname
  • xtasks/fig/src/mise.ts: Regenerated file from render task

Fixes autofix CI failure in #7010

🤖 Generated with Claude Code


Note

Fixes ESM __dirname error and updates the Fig spec to use new, debounced generators for richer completions across commands.

  • Fig tooling:
    • Add ESM-compatible __dirname in xtasks/fig/addCustomGenerators.ts using import.meta.url.
  • Autocomplete spec (xtasks/fig/src/mise.ts):
    • Introduce rich generators (toolVersionGenerator, installedToolVersionGenerator, pluginGenerator, aliasGenerator, settingsGenerator, configPathGenerator) and backend/package search helpers.
    • Replace many inline shell-based completion templates with the new generators and add debounce: true to arguments across commands.
    • Enhance completions for tools, versions, plugins, tasks, settings, and config paths; add GitHub/registry/backends search support.

Written by Cursor Bugbot for commit 2886f1b. This will update automatically on new commits. Configure here.

Fix ReferenceError where __dirname is not defined in ES modules by
importing fileURLToPath and calculating __dirname from import.meta.url.

Also update generated mise.ts file from render task.

Fixes autofix CI failure in #7010

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings November 20, 2025 01:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a ReferenceError in the fig autocomplete generation task where __dirname was undefined because the code runs as an ES module rather than CommonJS. The fix adds ES module-compatible directory path resolution using import.meta.url.

Key changes:

  • Added ES module-compatible __dirname calculation in addCustomGenerators.ts
  • Regenerated mise.ts with updated custom generators and debounce flags

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
xtasks/fig/addCustomGenerators.ts Added ES module-compatible __dirname using fileURLToPath and import.meta.url
xtasks/fig/src/mise.ts Regenerated file with custom generators replacing bash completion templates and added debounce flags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jdx jdx enabled auto-merge (squash) November 20, 2025 01:21
Disable MD060 (table-column-style) markdownlint rule as it conflicts
with prettier formatting. Prettier reformats tables with emojis that
have different character widths, causing MD060 violations that cannot
be auto-fixed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@jdx jdx merged commit 019ab03 into main Nov 20, 2025
28 checks passed
@jdx jdx deleted the fix/autofix-ci-errors branch November 20, 2025 01:37
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.6 x -- echo 20.3 ± 0.8 19.5 37.7 1.00
mise x -- echo 21.0 ± 0.3 20.0 22.7 1.03 ± 0.05

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.6 env 19.8 ± 0.6 18.9 25.8 1.00
mise env 20.5 ± 0.4 19.3 24.7 1.04 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.6 hook-env 19.8 ± 0.3 19.1 20.7 1.00
mise hook-env 20.6 ± 0.9 19.5 39.1 1.04 ± 0.05

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.6 ls 17.3 ± 0.3 16.3 18.8 1.00
mise ls 18.0 ± 0.4 16.8 20.3 1.04 ± 0.03

xtasks/test/perf

Command mise-2025.11.6 mise Variance
install (cached) 112ms 111ms +0%
ls (cached) 67ms 68ms -1%
bin-paths (cached) 74ms 74ms +0%
task-ls (cached) 458ms 452ms +1%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants