u/LeftAd1220

▲ 0 r/bun

How I Disabled Headless Mode in Bun.WebView's Chrome Backend

Conclusion

  • Only a one-byte binary patch required from --headless to --leadless (or other same length unknown flag)

How I did it

  • bunx jsmdcui --hex3 $(which bun)
  • Ctrl-F -..-..h..e..a..d..l..e..s..s..
  • Enter
  • Change h to l
  • Ctrl-E save bun-revised
  • Ctrl-Q
  • chmod +x bun-revised
  • ./bun-revised official-webview-demo.js
  • Tested on CachyOS Linux-x86_64

Disclaimer

  • This is completely unofficial
  • For fun only
  • Use it at your own risk
  • We should patiently wait for headless: false.
reddit.com
u/LeftAd1220 — 6 days ago
▲ 0 r/bun

Bun's Android build isn't just another platform target to me. It's an escape hatch.

First of all, thank you so much to the Bun team for supporting Android.

It's hard to realize just how much this means to Android users.

Traditionally, mobile platforms have been treated as inferior computing environments, unable to run many of the tools we take for granted on desktop Linux. Termux completely changed that story by giving Android a native shell environment.

But that freedom comes at a price.

Android uses Bionic libc rather than glibc, which means Linux tools generally need to be rebuilt specifically for the Android environment. Much like the situation with musl-based distributions, you can't simply assume that an arbitrary Linux binary, even if built for arm64, will run.

The enormous package ecosystem that makes Termux so powerful is maintained largely by volunteer developers, and I've always had this fear in the back of my mind: what if one day that package ecosystem is no longer maintained?

So after years of using Node.js and Bun, I've gradually built my own collection of basic tools in JavaScript. Part of the motivation was simple: I wanted to make sure that no matter what happens to the surrounding ecosystem, I can still have a useful shell environment on Android.

And this is where Bun's Android build becomes much more than just another platform target to me.

It's the seed that lets me rebuild everything else.

As long as I can use Android's ProcessBuilder to spawn a Bun binary, I have JavaScript. I have my own tools. I have bunx. I have the whole npm ecosystem. I can start servers, build terminal interfaces, and gradually bootstrap the rest of my environment.

I no longer need to depend on someone else rebuilding every tool I need against Bionic libc.

Platforms can change. Package repositories can disappear. Maintainers can move on.

But as long as I can still ignite that one Bun binary on Android, I have an escape hatch back to a real computing environment.

On Linux, we have Linux From Scratch.

Now on Android, I guess we have Shell From Scratch.

Once Bun is alive, the next step is surprisingly simple: Bun spawns my jsgotty, which exposes a real PTY-backed terminal through a local web server. I point an Android WebView at it, and suddenly:

we have the shell back.

No terminal emulator to depend on. No existing shell environment required. Just an Android app, a Bun binary, and JavaScript bootstrapping its own terminal.

And once I have a shell, things start getting interesting.

Because a shell is enough to launch proot.

And with proot I can finally embrace the glorious Debian and Alpine repositories with apt and apk.

Thousands upon thousands of packages, maintained for standard Linux environments, are suddenly within reach.

The shell has grown into real Linux.

reddit.com
u/LeftAd1220 — 14 days ago
▲ 5 r/bun

Interactive shell with Bun?

Has anyone built (or heard of) an interactive shell like Fish, Bash, or Zsh using Bun?

I'm not referring to the official Bun Shell ($) api.

I mean a real interactive shell with a prompt, history, completion, and persistent sessions.

I couldn't find any mature projects, so I'm wondering if I missed one.

reddit.com
u/LeftAd1220 — 22 days ago
▲ 3 r/bun

A surprising --define process.env edge case when building a Bun single-file executable

I was trying to inline the build-time constant process.env.MYVAR and passed the define in the right JSON quoted form in fish:

--define 'process.env.MYVAR="myval"'

At other sites it worked but specifically in one of my source files it didn't get inlined.

After some debugging, it turned out the culprit was this innocent-looking line:

import process from "node:process";

This line gets added at some point by an AI and I thought this wouldn't make a big difference. But during bundling, Bun renamed the imported binding (for example to y), so the --define process.env.MYVAR=... replacement no longer matched that expression.

reddit.com
u/LeftAd1220 — 25 days ago
▲ 0 r/bun

I made Markdown executable: the same .md runs as both a terminal UI and a browser UI

https://github.com/jjtseng93/jsmdcui

One Markdown file. Two UIs.

  • TUI = Terminal User Interface
  • WUI = Web User Interface

⚡ No build step

🚀 Write & run an interactive application using a single Markdown file.

📝 UI = Markdown

💻 Logic = JavaScript (Bun)

📄 The same .md runs in both UIs

🖥 Tested platforms: Windows • Linux • Android

📦 Reusable single-file executable template for your own JS project

u/LeftAd1220 — 1 month ago
▲ 37 r/termux

I ran Flatpak on Android Termux using proot

https://github.com/jjtseng93/termux-proot-for-flatpak

Intro

  • No root, no adb, no manual extraction
  • I can't thank you enough, sylirre !
  • I noticed from the Termux proot github history a while ago that they've added bwrap support thanks to sylirre
  • bwrap is the core of Flatpaks
  • so I thought maybe we could run Flatpaks in proot
  • Now here it is! This is an unofficial fork of Termux proot. After many iterations with Codex and Claude to revise proot (and exhausting plenty of tokens 😅), plus a few hacky LD_PRELOAD libraries, I finally got Flatpak apps running.
  • I've successfully ran org.gnome.Calculator for now
  • Hopefully, something like this might be officially supported in the future?

What this implies

  • This significantly expands the available software sources, making many more applications accessible through Flatpak while remaining entirely in a rootless proot environment.
u/LeftAd1220 — 2 months ago
▲ 0 r/bun

I rewrote the micro editor in JavaScript using Bun

Features

  • JavaScript plugins / commands
  • Long line protection for minified files (e.g. vue.min.js)
  • Open URLs directly
  • Text-To-Speech(tts) support
  • Android-friendly text selection
  • bat-like syntax highlighting to the terminal

Portability

  • One codebase. One folder.
  • Runs on Windows, Android, Linux
  • No per-platform builds
  • No native bindings
  • No recompilation
  • Just copy the folder and run it with Bun

GitHub repo

Try it

  • npm install -g bun
  • npx bunmicro
u/LeftAd1220 — 3 months ago
▲ 0 r/termux

bun 1.3.14 officially supports Android, but it's not faster than node

  • node/bun(Android): 660ms
  • bun(glibc on Android): 88ms
  • .
  • I have always been a fan of Bun due to its speed and rich features, and I'm very glad they have built it on Android in the latest version: 1.3.14.
  • However, after testing it with a small piece of benchmarking code, I found that the Android build was not faster than glibc builds or Android Node.js:

​

function heavy(n) {
  let s = 0;
  for (let i = 1; i < n; i++) {
    s += Math.sqrt(i) * Math.sin(i);
  }
  return s;
}

const t0 = performance.now();
const result = heavy(8_000_000);
const t1 = performance.now();

console.log("Result:", result);
console.log("Time:", (t1 - t0).toFixed(2), "ms");
  • glibc build can be run by glibc-runner (termux native) or proot debian and both get the faster result
  • I believe their optimizations might only apply to glibc. Even musl builds are not that fast.
  • While this might defeat the purpose of using Bun, it still has lots of extra features like pseudo-terminal, image resize/rotate, and all kinds of database clients, just to name a few
  • Luckily, os.networkInterfaces() is not broken
  • process.platform is android, same as Node.js, which might break some native bindings
u/LeftAd1220 — 3 months ago