Skip to content

bunx behaviour, cli inconsistencies with bun x #5030

Closed

Description

@kanashimia

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 6.5.1 x86_64 unknown

What steps can reproduce the bug?

$ bunx --bun echo

$ bun x --bun echo
--bun

$ bun --bun x echo

$ bunx -b echo   
-b

$ bun x -b echo   
-b

$ bun -b x echo   
-b

$ bunx --help echo --help echo --help   
--help --help echo --help

$ bunx /usr/bin/env echo
error: unrecognised dependency format: @/usr/bin/env

$ bunx env echo         

What is the expected behavior?

The following assumes that echo is a npm package that prints CLI arguments, instead of an actual echo package.
In reality it should show error: could not determine executable to run for package echo

$ bunx --bun echo

$ bun x --bun echo

$ bun --bun x echo

$ bunx -b echo   

$ bun x -b echo   

$ bun -b x echo

$ bunx --help echo --help echo --help   
usage: bunx [bun flags]... package[@version] [flags or arguments to pass through]...

bunx runs an npm package executable, automatically installing into a global shared cache if not installed in node_modules.

...omitted

$ bunx /usr/bin/env echo
error: unrecognised dependency format: @/usr/bin/env

$ bunx env echo         
error: could not determine executable to run for package env

There a many points for consideration, npm and pnpm are weird in their CLI.

I suggest the following:

  1. correctly add -b flag as alias for --bun

  2. every argument that starts with - is a flag to bun until a required flag that starts with anything else is encountered
    bunx [bun_flags]... package[@version] [pkg_args]...
    bun [bun_flags]... x [bun_flags]... package[@version] [pkg_args]...

  3. bunx and bun x should have exactly the same behaviour, note that this is not the case for npm or pnpm

  4. add npm -c flag alternative to run files in the shell, my suggestion is
    bun shell [-p <pkg>]... [cmd_and_args]...

  5. add exec command and make x an alias of it

Point [4] requires standalone issue.

What do you see instead?

No response

Additional information

Related issue #4972

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliSomething to do with CLI arguments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions