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

execa $ doesn't work with stdio: inherit #7068

Open
jcbhmr opened this issue Nov 12, 2023 · 2 comments
Open

execa $ doesn't work with stdio: inherit #7068

jcbhmr opened this issue Nov 12, 2023 · 2 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@jcbhmr
Copy link

jcbhmr commented Nov 12, 2023

What version of Bun is running?

1.0.11+f7f6233ea

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

import { $ } from "execa"
const args = ["hello", "world"]
await $({ stdio: "inherit" })`echo ${args}`
bun index.js

What is the expected behavior?

hello world

What do you see instead?

hello world
1 | export const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => {
2 |     if (!isAsyncIterable(stream)) {
3 |             throw new Error('The first argument must be a Readable, a ReadableStream, or an async iterable.');
            ^
error: Command failed: echo hello world
The first argument must be a Readable, a ReadableStream, or an async iterable.
      at /home/jcbhmr/.bun/install/cache/[email protected]/source/contents.js:3:8
      at getStreamContents (/home/jcbhmr/.bun/install/cache/[email protected]/source/contents.js:1:40)
      at getStreamAsString (/home/jcbhmr/.bun/install/cache/[email protected]/source/string.js:4:40)
      at /home/jcbhmr/.bun/install/cache/[email protected]/lib/stream.js:119:23
      at getSpawnedResult (/home/jcbhmr/.bun/install/cache/[email protected]/lib/stream.js:118:32)
      at /home/jcbhmr/.bun/install/cache/[email protected]/index.js:118:93
      at /home/jcbhmr/.bun/install/cache/[email protected]/index.js:117:23
      at onetime (/home/jcbhmr/.bun/install/cache/[email protected]/index.js:18:17)
      at /home/jcbhmr/.bun/install/cache/[email protected]/lib/promise.js:15:34
      at processTicksAndRejections (:61:76)

Additional information

this also doesn't work:

import { $ } from "execa"
const arg = "hello world"
await $({ stdio: "inherit" })`echo ${arg}`
hello world
error: Command failed: echo hello world
The first argument must be a Readable, a ReadableStream, or an async iterable.

but this does work:

import { $ } from "execa"
const args = ["hello", "world"]
const { stdout } = await $`echo ${args}`
console.log(stdout)
hello world

as does this

import { $ } from "execa"
const arg = "hello world"
const { stdout } = await $`echo ${arg}`
console.log(stdout)
hello world
@jcbhmr jcbhmr added the bug Something isn't working label Nov 12, 2023
@Electroid Electroid added the node.js Compatibility with Node.js APIs label Nov 13, 2023
@elie222
Copy link

elie222 commented Dec 1, 2023

Ran into a similar issue. npx tsx worked. bun didn't. i was also getting silent errors with bun.

@SrBrahma
Copy link

SrBrahma commented Dec 18, 2023

execaCommand and execa have the same issue. https://bun.sh/docs/api/spawn can be an alternative in the meantime.

Edit: Tbh, I even preferred the bun's spawn as it's one dep less (two, including @types) to be installed. It could support string as a param instead of an array, like execaCommand does.

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

No branches or pull requests

4 participants