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

TSC from Shell ($) should pass-through ANSI Color, and not print "ugly" stdout: Buffer(1415) [ 115, 114, ... #16496

Open
vorburger opened this issue Jan 18, 2025 · 3 comments
Labels
bug Something isn't working shell Something to do with Bun as a shell

Comments

@vorburger
Copy link

What version of Bun is running?

1.1.45+196621f25

What platform is your computer?

Linux 6.10.11

What steps can reproduce the bug?

await $`bun tsc` 

What is the expected behavior?

I would have expected to see the same output as when I launch bun tsc from my shell, with pretty colors:

src/browser/index.ts:39:25 - error TS2345: Argument of type ...

Found 7 errors in 4 files.

Errors  Files
     2  src/browser/index.ts:39
     3  src/bun/build.ts:3
     1  src/common/string2long.test.ts:1
     1  tsconfig.json:41
error: "tsc" exited with code 1

PS: I cannot (easily) provide/show you the colors here, but you'll know what I mean.

What do you see instead?

I'm seeing this instead, without (!) the colors, and with what too many as an end-user looks like a too internal technical stdout: Buffer and stderr: Buffer:

src/browser/index.ts(39,25): error TS2345: Argument of type ...

error: "tsc" exited with code 1
ShellError: Failed with exit code 1
 exitCode: 1,
   stdout: Buffer(1415) [ 115, 114, 99, 47, 98, 114, 111, 119, 115, 101, 114, 47, 105, 110, 100, 101, 120, 46, 116, 115, 40, 51, 57, 44, 50, 53, 41, 58, 32, 101, 114, 114, 111, 114, 32, 84, 83, 50, 51, 52, 53, 58, 32, 65, 114, 103, 117, 109, 101, 110, 116, 32, 111, 102, 32, 116, 121, 112, 101, 32, 39, 116, 121, 112, 101, 111, 102, 32, 105, 109, 112, 111, 114, 116, 40, 34, 47, 104, 111, 109, 101, 47, 118, 111, 114, 98, 117, 114, 103, 101, 114, 47, 103, 105, 116, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 101, 110, 111, 108, 97, 45, 100, 101, 118, 47, 101, 110, 111, 108, 97, 47, 119, 101, 98, 47, 110, 111, 100, 101, 95, 109, 111, 100, 117, 108, 101, 115, 47, 103, 114, 97, 112, 104, 111, 108, 111, 103, 121, 47, 100, 105, 115, 116, 47, 103, 114, 97, 112, 104, 111, 108, 111, 103, 121, 34, 41, 39, 32, 105, 115, 32, 110, 111, 116, 32, 97, 115, 115, 105, 103, 110, 97, 98, 108, 101, 32, 116, 111, 32, 112, 97, 114, 97, 109, 101, 116, 101, 114, 32, 111, 102, 32, 116, 121, 112, 101, 32, 39, 71, 114, 97, 112, 104, 67, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 60, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 44, 32, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 44, 32, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 62, 39, 46, 10, 32, 32, 84, 121, 112, 101, 32, 39, 116, 121, 112, 101, 111, 102, 32, 105, 109, 112, 111, 114, 116, 40, 34, 47, 104, 111, 109, 101, 47, 118, 111, 114, 98, 117, 114, 103, 101, 114, 47, 103, 105, 116, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 101, 110, 111, 108, 97, 45, 100, 101, 118, 47, 101, 110, 111, 108, 97, 47, 119, 101, 98, 47, 110, 111, 100, 101, 95, 109, 111, 100, 117, 108, 101, 115, 47, 103, 114, 97, 112, 104, 111, 108, 111, 103, 121, 47, 100, 105, 115, 116, 47, 103, 114, 97, 112, 104, 111, 108, 111, 103, 121, 34, 41, 39, 32, 112, 114, 111, 118, 105, 100, 101, 115, 32, 110, 111, 32, 109, 97, 116, 99, 104, 32, 102, 111, 114, 32, 116, 104, 101, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 32, 39, 110, 101, 119, 32, 40, 111, 112, 116, 105, 111, 110, 115, 63, 58, 32, 71, 114, 97, 112, 104, 79, 112, 116, 105, 111, 110, 115, 32, 124, 32, 117, 110, 100, 101, 102, 105, 110, 101, 100, 41, 58, 32, 65, 98, 115, 116, 114, 97, 99, 116, 71, 114, 97, 112, 104, 60, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 44, 32, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 44, 32, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 62, 39, 46, 10, ... 902 more ],
   stderr: Buffer(32) [ 101, 114, 114, 111, 114, 58, 32, 34, 116, 115, 99, 34, 32, 101, 120, 105, 116, 101, 100, 32, 119, 105, 116, 104, 32, 99, 111, 100, 101, 32, 49, 10 ],

      at ShellError (unknown:12:16)
      at ShellPromise (unknown:77:16)
      at BunShell (unknown:193:35)

Bun v1.1.45 (Linux x64)

Additional information

I do perfectly understand why this is technically happening (the exec-ed tool cannot detect whether the "Bun terminal"; whatever tsc uses, whether something like https://github.com/chalk/supports-color for https://no-color.org/ and https://force-color.org/ or its own algorithm; but this of course isn't specific to tsc but more generic), etc.

In a "perfect world", it would be very cool if this "just worked", out of the box.

@vorburger vorburger added bug Something isn't working needs triage labels Jan 18, 2025
@RiskyMH RiskyMH added shell Something to do with Bun as a shell and removed needs triage labels Jan 18, 2025
@RiskyMH
Copy link
Member

RiskyMH commented Jan 18, 2025

yeah indeed, also related to #10346

@vorburger vorburger changed the title Shell ($) should pass-through ANSI Color, and not print "ugly" stdout: Buffer(1415) [ 115, 114, ... TSC from Shell ($) should pass-through ANSI Color, and not print "ugly" stdout: Buffer(1415) [ 115, 114, ... Jan 19, 2025
@vorburger
Copy link
Author

vorburger commented Jan 19, 2025

FTR: This appears to be specific to tsc?! Or at least it, and maybe other tools, depending on how they detect their terminal - but I've just noticed that what I describe above does not seem to affect e.g. an "await $`bun test`"... that works just fine - with colors, and without the Buffer thing.

BTW: A ("naive") attempt of using "await $`FORCE_COLORS=1 && echo $FORCE_COLORS && bun tsc`" does not fix it.

@vorburger
Copy link
Author

Let's actually split out the 🎨 color aspect from the Buffer thing, and keep this issue for the former, and use #16533 for the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working shell Something to do with Bun as a shell
Projects
None yet
Development

No branches or pull requests

2 participants