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

Bug: Fatal Error when running on MacOS #193

Open
Malaeu opened this issue Dec 6, 2024 · 3 comments
Open

Bug: Fatal Error when running on MacOS #193

Malaeu opened this issue Dec 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Malaeu
Copy link

Malaeu commented Dec 6, 2024

Environment:

  • OS: MacOS
  • Node: v22.12.0
  • NPM: v10.9.0

Error:
spawnSync sysctl ENOENT

The package tries to load Windows-specific code (clipboardy/lib/windows.js) on MacOS, causing fatal error. This happens both with global npm install and npx.

Steps to reproduce:

  1. npm install -g repomix or npx repomix
  2. Run repomix --version
@yamadashy
Copy link
Owner

Hi, @Malaeu !
Thank you for reporting this issue!

I tried reproducing with the exact same environment (MacOS, Node v22.12.0, NPM v10.9.0) but couldn't replicate the error. To help track this down, could you share:

  1. Your MacOS version (Apple menu > About This Mac)
  2. The complete error stack trace

This will help us identify and fix the root cause. Thanks for helping improve Repomix!

@yamadashy yamadashy added the bug Something isn't working label Dec 8, 2024
@rockmandash
Copy link

I just asked o1 pro about this problem and here is the response:

Clipboardy Issue on macOS with Repomix

The root issue here is that clipboardy is incorrectly loading its Windows-specific code path on macOS, resulting in:

spawnSync sysctl ENOENT
Error: The package tries to load Windows-specific code (clipboardy/lib/windows.js) on MacOS

Below are a few details and workarounds:

1. Why This Happens

  • OS-Specific Code Paths: Clipboardy uses different code paths for each OS. Ideally, if process.platform === 'darwin', it should load macOS logic.
  • Environment Variables/Node.js Version: Sometimes, environment variables or an unusual Node.js version (e.g., v22.12.0, which is quite new and not LTS) can confuse clipboardy’s OS detection.
  • Clipboardy Bug: Alternatively, it could be a bug in the version of clipboardy that Repomix depends on, causing it to incorrectly import the Windows module on a macOS system.

2. Workarounds to Get Repomix Running

1. Disable Clipboard Copy

If you don’t actually need Repomix to copy the output to your clipboard, you can turn that off. Repomix only attempts to import and call clipboardy if copyToClipboard: true in your config. To disable it:

  • In your repomix.config.json:
{
  "output": {
    "copyToClipboard": false
  }
}
  • From the CLI:

Just don’t pass --copy. (By default, it’s false anyway.)

This prevents Repomix from needing clipboardy at all, avoiding the Windows code path entirely.

2. Try a Different Node Version

Because Node.js 22.x is not yet an official LTS or stable release, you could try Node 20.x or 18.x to see if the problem goes away. Some older modules or environment detection code might not handle 22.x well.

3. Ensure macOS Tools Are in PATH

Check that sysctl (and other standard macOS commands) are accessible in your PATH:

which sysctl

If it prints something like /usr/sbin/sysctl, then your PATH is normal. If it says “not found,” something about your environment may be unusual.

4. Install a Different Clipboardy Version (Advanced)

If you absolutely need to keep copyToClipboard set to true, you could override the clipboardy version in node_modules with a patch or a newer release that might fix the bug. This is a more advanced approach:

  • Use Yarn “resolutions” or npm “overrides” to force a certain version of clipboardy.
  • If the bug is in older clipboardy, upgrading might fix it. If it’s in a newer clipboardy, rolling back might fix it.

However, this can get messy quickly.

5. Open a GitHub Issue

If none of the above help, please open an issue on the Repomix repo or clipboardy repo. Provide:

  • node --version
  • npm --version
  • process.platform and environment details
  • The full error stack trace

3. Summary

  • Cause: The error indicates the macOS environment is loading Windows clipboard code from clipboardy, triggering a fatal ENOENT when it tries to spawn a Windows command.
  • Solution: Disabling Repomix’s “copy to clipboard” feature (i.e., "copyToClipboard": false) typically bypasses clipboardy usage entirely, which often solves the crash on macOS.
  • Alternatives: If you do need the clipboard feature, try using Node 18.x or 20.x (or check for a bug with clipboardy and Node 22.x).

This should unblock you from the fatal error on macOS and let Repomix run successfully. If it continues, consider opening a detailed issue for further debugging.

@Malaeu
Copy link
Author

Malaeu commented Jan 1, 2025

Wau! Thx so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants