-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
error: unknown command with a -e flag (bun) #2205
Comments
The
Are you seeing those in the error message? (I am wondering if the error might be coming from something else, although looks pretty similar, so just checking!) |
i'm using bun to run it. I had someone else reproduce it with this on their machine and confirmed they also see this issue. it is like the |
I have reproduced what I think is the same issue. Try changing the parse call and see if it fixes your problem. From your example code:
What I suspect is happening is that bun is incorrectly including script arguments into // args.js
console.log({ argv: process.argv, execArgv: process.execArgv }); % node args.js debug -e dev
{
argv: [
'/usr/local/bin/node',
'/Users/john/Documents/Sandpits/commander/issues/2205/args.js',
'debug',
'-e',
'dev'
],
execArgv: []
}
% bun run args.js debug -e dev
{
argv: [ "/opt/homebrew/Cellar/bun/1.1.9/bin/bun", "/Users/john/Documents/Sandpits/commander/issues/2205/args.js",
"debug", "-e", "dev"
],
execArgv: [ "-e" ],
} Running a program based on your example code, the script name is being parsed by Commander as a command name: % bun run cli.ts debug -e dev
error: unknown command '/Users/john/Documents/Sandpits/commander/issues/2205/cli.ts' Reference: https://nodejs.org/docs/latest/api/process.html#processexecargv
|
This has appeared in Commander v12.1.0 because of #2164 which added detection of |
Yes, that does allow it to run through the command chain. |
I have opened an issue against Bun. If it doesn't get positive activity, I will add a work-around in Commander. |
Will be fixed in oven-sh/bun#11987, likely landing in Bun 1.1.15 or 16 (probably within a week) |
This is fixed in Bun v1.1.16, thanks to @paperdave |
I had the following code for version 9.4.1. When I upgraded to 12.1.0 this no longer works.
When I execute
cli.ts debug -e dev
When I execute
cli.ts debug --env dev
, it works fine.If I change the code to use
-a, --env <string>
, then when I executecli.ts debug -a dev
it works fine.cli.ts
debug.ts
The text was updated successfully, but these errors were encountered: