Skip to content

Commit 88b7fde

Browse files
committed
fix(install): use bun x instead of bunx for DLX commands
Some installation methods (e.g. mise) don't add `bunx` exe to PATH on Windows. Using `bun x` (subcommand) instead of `bunx` (separate binary) is more reliable across platforms and calls fewer binaries. Closes #1005
1 parent 66474e1 commit 88b7fde

4 files changed

Lines changed: 27 additions & 24 deletions

File tree

crates/vite_install/src/commands/dlx.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ impl PackageManager {
196196
) -> ResolveCommandResult {
197197
let mut args = Vec::new();
198198

199-
// bunx is the dlx equivalent, no subcommand needed
199+
// Use `bun x` instead of `bunx` for better cross-platform compatibility.
200+
// Some installation methods (e.g. mise) don't add bunx to PATH on Windows.
201+
args.push("x".into());
202+
200203
// Add package spec
201204
args.push(options.package_spec.into());
202205

@@ -205,13 +208,13 @@ impl PackageManager {
205208

206209
// Warn about unsupported flags
207210
if !options.packages.is_empty() {
208-
output::warn("bunx does not support --package");
211+
output::warn("bun x does not support --package");
209212
}
210213
if options.shell_mode {
211-
output::warn("bunx does not support shell mode (-c)");
214+
output::warn("bun x does not support shell mode (-c)");
212215
}
213216

214-
ResolveCommandResult { bin_path: "bunx".into(), args, envs }
217+
ResolveCommandResult { bin_path: "bun".into(), args, envs }
215218
}
216219
}
217220

packages/cli/src/create/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function getPackageRunner(workspaceInfo: WorkspaceInfo) {
154154
args: ['dlx'],
155155
};
156156
case 'bun':
157-
return { command: 'bunx', args: [] };
157+
return { command: 'bun', args: ['x'] };
158158
case 'npm':
159159
default:
160160
return { command: 'npx', args: [] };

rfcs/dlx-command.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ vp dlx -p typescript -p @types/node -c 'tsc --init && node -e "console.log(123)"
104104
- pnpm: https://pnpm.io/cli/dlx
105105
- npm: https://docs.npmjs.com/cli/v10/commands/npm-exec
106106
- yarn: https://yarnpkg.com/cli/dlx
107-
- bun: https://bun.sh/docs/cli/bunx
107+
- bun: https://bun.sh/docs/pm/bunx
108108

109-
| Vite+ Flag | pnpm | npm | yarn@1 | yarn@2+ | bun | Description |
110-
| ------------------------------- | ------------------ | ------------------- | ----------- | ---------------- | ------------ | -------------------------- |
111-
| `vp dlx <pkg>` | `pnpm dlx <pkg>` | `npm exec <pkg>` | `npx <pkg>` | `yarn dlx <pkg>` | `bunx <pkg>` | Execute package binary |
112-
| `--package <name>`, `-p <name>` | `--package <name>` | `--package=<name>` | N/A | `-p <name>` | N/A | Specify package to install |
113-
| `--shell-mode`, `-c` | `-c` | `-c` | N/A | N/A | N/A | Execute in shell |
114-
| `--silent`, `-s` | `--silent` | `--loglevel silent` | `--quiet` | `--quiet` | N/A | Suppress output |
109+
| Vite+ Flag | pnpm | npm | yarn@1 | yarn@2+ | bun | Description |
110+
| ------------------------------- | ------------------ | ------------------- | ----------- | ---------------- | ------------- | -------------------------- |
111+
| `vp dlx <pkg>` | `pnpm dlx <pkg>` | `npm exec <pkg>` | `npx <pkg>` | `yarn dlx <pkg>` | `bun x <pkg>` | Execute package binary |
112+
| `--package <name>`, `-p <name>` | `--package <name>` | `--package=<name>` | N/A | `-p <name>` | N/A | Specify package to install |
113+
| `--shell-mode`, `-c` | `-c` | `-c` | N/A | N/A | N/A | Execute in shell |
114+
| `--silent`, `-s` | `--silent` | `--loglevel silent` | `--quiet` | `--quiet` | N/A | Suppress output |
115115

116116
**Notes:**
117117

@@ -120,7 +120,7 @@ vp dlx -p typescript -p @types/node -c 'tsc --init && node -e "console.log(123)"
120120
- **Shell mode**: Yarn 2+ does not support shell mode (`-c`), command will print a warning and try to execute anyway.
121121
- **--package flag position**: For pnpm, `--package` comes before `dlx`. For npm, `--package` can be anywhere. For yarn, `-p` comes after `dlx`.
122122
- **Auto-confirm prompts**: For npm and npx (yarn@1 fallback), `--yes` is automatically added to align with pnpm's behavior which doesn't require confirmation.
123-
- **bun**: Uses `bunx` as a standalone binary (not a subcommand of `bun`). It does not support `--package`, `--shell-mode`, or `--silent` flags.
123+
- **bun**: Uses `bun x` subcommand (preferred over the `bunx` standalone binary for better cross-platform compatibility). It does not support `--package`, `--shell-mode`, or `--silent` flags.
124124

125125
### Argument Handling
126126

@@ -721,7 +721,7 @@ Error: yarn@1.22.19 does not support dlx command
721721

722722
- Frustrating user experience
723723
- npx fallback works well and is available
724-
- Other tools (like bunx) also provide fallbacks
724+
- Other tools (like `bun x`) also provide fallbacks
725725
- Users shouldn't need to switch package managers for dlx
726726

727727
## Implementation Plan
@@ -890,14 +890,14 @@ Examples:
890890
891891
## Package Manager Compatibility
892892
893-
| Feature | pnpm | npm | yarn@1 | yarn@2+ | bun | Notes |
894-
| ----------------- | ------- | ------- | ------- | ------- | --------- | ------------------------- |
895-
| Basic execution | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ✅ `bunx` | yarn@1 uses npx fallback |
896-
| Version specifier | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ✅ Full | |
897-
| --package flag | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ❌ N/A | bunx doesn't support |
898-
| Shell mode (-c) | ✅ Full | ✅ Full | ⚠️ npx | ❌ N/A | ❌ N/A | yarn@2+/bun don't support |
899-
| Silent mode | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ❌ N/A | bunx doesn't support |
900-
| Auto-confirm | ✅ N/A | ✅ Auto | ⚠️ Auto | ✅ N/A | ✅ N/A | --yes added for npm/npx |
893+
| Feature | pnpm | npm | yarn@1 | yarn@2+ | bun | Notes |
894+
| ----------------- | ------- | ------- | ------- | ------- | ---------- | ------------------------- |
895+
| Basic execution | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ✅ `bun x` | yarn@1 uses npx fallback |
896+
| Version specifier | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ✅ Full | |
897+
| --package flag | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ❌ N/A | `bun x` doesn't support |
898+
| Shell mode (-c) | ✅ Full | ✅ Full | ⚠️ npx | ❌ N/A | ❌ N/A | yarn@2+/bun don't support |
899+
| Silent mode | ✅ Full | ✅ Full | ⚠️ npx | ✅ Full | ❌ N/A | `bun x` doesn't support |
900+
| Auto-confirm | ✅ N/A | ✅ Auto | ⚠️ Auto | ✅ N/A | ✅ N/A | --yes added for npm/npx |
901901

902902
## Security Considerations
903903

rfcs/exec-command.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ The command completes the execution story alongside existing commands:
88

99
| Command | Behavior | Analogy |
1010
| ------------- | -------------------------------------------------------------- | --------------------------- |
11-
| `vp dlx` | Always downloads from remote | `pnpm dlx` / `bunx` |
11+
| `vp dlx` | Always downloads from remote | `pnpm dlx` / `bun x` |
1212
| `vpx` | Local → global → PATH → remote fallback | `npx` |
1313
| **`vp exec`** | **Prepend `node_modules/.bin` to PATH, then execute normally** | **`pnpm exec`** / **`bun`** |
1414

15-
**Note:** bun natively resolves binaries from local `node_modules/.bin`, so `bun <cmd>` or `bunx <cmd>` can serve a similar purpose to `vp exec`.
15+
**Note:** bun natively resolves binaries from local `node_modules/.bin`, so `bun <cmd>` or `bun x <cmd>` can serve a similar purpose to `vp exec`.
1616

1717
## Motivation
1818

0 commit comments

Comments
 (0)