-
-
Notifications
You must be signed in to change notification settings - Fork 157
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] 'moon' is not recognized as an internal or external command, operable program or batch file. #1468
Comments
Creating a stub binary like this comment suggests, might be an easy solution |
So we actually do have a stub file: https://github.com/moonrepo/moon/blob/master/packages/cli/moon But maybe it needs to be a bash script? I'm also not positive if npx runs post installs? |
Thanks for the quick reply!
Well
Maybe. Though the stub file apparently gets removed after the first installation. On my windows machine I only see the I quickly looked how other packages, that use post-installed binary executables handle this (e.g. electron, esbuild, playwright-core). It seems they all use a node.js script that calls the binary via |
This is basically also what the comment that I linked above suggested. He didn't actually create an empty stub file, but a node.js script that calls the executable. Here is the file from the repo that he linked: #!/usr/bin/env node
/**
* This file is a pass-through for the actual just binary. It exists because for two reasons:
*
* - Yarn does not allow references to anything other than .js files in the "bin" field in package.json.
* - Windows does not allow executing binaries that don't end in .exe, and we need the package.json "bin" field to
* point to the same file on all platforms.
*/
import child_process from 'node:child_process';
import path from 'node:path';
import process from 'node:process';
import url from "url";
const ext = process.platform === 'win32' ? '.exe' : '';
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
child_process.execFileSync(
path.resolve(__dirname, 'just' + ext),
process.argv.slice(2),
{ stdio: 'inherit' }
); |
Thanks, I'll dig further. I'm still curious why this is only happening to you at the moment. We have a lot of Windows users, and Yarn users, and this hasn't crept up yet. |
I was asking myself the same thing. Maybe it's because I am using Yarn 3/4 and not Yarn 1... Though even then, the combination of Windows and Yarn 2+ should be common enough... |
Ok, I dug a little deeper and realized that this problem also happens with Even directly calling Tests with
|
p.s. I also checked: |
Thanks for debugging! I think the easiest solution here is to just have a node script call a child process like you mentioned above. I can easily tackle this on Monday. |
great, thanks! Btw, I think one of the problematic code lines is this one in main.rs. This one will fail to remove the binary path on windows, if it does not end with I still don't understand though why calling moon with a relative path, e.g. |
Describe the bug
The
moon.cmd
is not properly set up, when installing@moonrepo/cli
version1.24.4
on Windows withyarn
. This may be related to this yarn bug. Unfortunately this makes moon mostly unusable for me.Steps to reproduce
Expected behavior
Moon binary should work.
Environment
Thank you for your help!
The text was updated successfully, but these errors were encountered: