---
title: Bun v1.1.1
description: "Fixes 20 bugs (addressing 60 👍). Add subshell and positional argument support to Bun Shell, fixing an issue with bun install + sharp on Windows. Printed source code in errors no longer fill up your terminal. Upgrades JavaScriptCore, which includes performance improvements to RegExp, typed arrays, String indexOf and String replace. Error objects and JIT'd function calls use less memory. Fixes several bugs with bun install on Windows. Fixes a bug with Bun.serve() on Windows. Fixes a TOML parser bug impacting escape sequences and windows paths in .toml files"
date: "2024-04-04T15:29:30.401Z"
author: jarred
draft: false
---

> Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager &mdash; all in one.

Bun v1.1.1 fixes 20 bugs (addressing 60 👍 reactions). Add subshell and positional argument support to Bun Shell, fixing an issue with bun install + sharp on Windows. Printed source code in errors no longer fill up your terminal. Upgrades JavaScriptCore, which includes performance improvements to RegExp, typed arrays, String indexOf and String replace. Error objects and JIT'd function calls use less memory. Fixes several bugs with bun install on Windows. Fixes a bug with Bun.serve() on Windows. Fixes a TOML parser bug impacting escape sequences and windows paths in .toml files.

#### Previous releases

- [`v1.1.0`](/blog/bun-v1.1) Bundows. Windows support is here! Plus, JSON IPC Node <-> Bun.
- [`v1.0.36`](/blog/bun-v1.0.36) Fixes 13 bugs. Adds support for `fs.openAsBlob` and `fs.opendir`, fixes edgecase in bun install with multiple `bin` entries in `package.json`, fixes `bun build --target bun` encoding, fixes bug with process.stdin & process.stdout, fixes bug in http2, fixes bug with .env in bun run, fixes various Bun shell bugs and improves Node.js compatibility.

#### To install Bun:

{% codetabs %}

```sh#curl
$ curl -fsSL https://bun.sh/install | bash
```

```sh#npm
$ npm install -g bun
```

```sh#powershell
$ powershell -c "irm bun.sh/install.ps1|iex"
```

```sh#scoop
$ scoop install bun
```

```sh#brew
$ brew tap oven-sh/bun
$ brew install bun
```

```sh#docker
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```

{% /codetabs %}

#### To upgrade Bun:

```sh
$ bun upgrade
```

### Windows support improvements

## Fixed: `bun install` failed to install sharp on Windows

Sharp would not install correctly on Windows due to an unimplemented feature in Bun Shell (which powers lifecycle scripts on Windows). This unimplemented feature has been implemented! Subshells are now supported in Bun Shell.

Our test suite will catch this bug in the future

## Fixed: bun install hanging on Windows

A bug that could cause `bun install` to hang for awhile has been fixed.

This bug happened when `ERROR_DELETE_PENDING` was returned by a Windows API. When a folder or file is being deleted but hasn't been fully deleted yet, Windows sometimes returns `ERROR_DELETE_PENDING`. The zig standard library handled this by sleeping for 1ms and then retrying the delete. This causes a race condition when one thread has the handle open and another thread is trying to delete the file. The other thread goes to sleep in a loop forever, and the other thread never gets the chance to delete the file.

Thanks to [@gvilums](https://github.com/gvilums) for fixing this issue.

## Fixed: spurious "Install failed" errors in `bun install` on Windows

A bug that could cause spurious "Install failed" errors in `bun install` has been fixed. This most frequently occurred when installing many packages simultaneously.

A similar bug involving `@scoped/package` scoped packages was also fixed.

#### Why did this happen?

Permissions in Windows are a bit weird. Opened file handles have a "Sharing Mode", which prevents other file handles from being opened on the same file without the same permissions. In the zig standard library, the `ERROR_SHARING_VIOLATION` error was not handled correctly. Separately, certain functions were also not requesting the same "Sharing Mode", which causes the `ERROR_SHARING_VIOLATION` error. If you've been unable to delete a file on Windows without closing applications, this is frequently the cause.

Thanks to [@gvilums](https://github.com/gvilums) for fixing this issue.

## Fixed: Workspace linking bug on Windows

A bug where `bun install` could return `error: Unexpected` while linking a workspace has been fixed.

This was caused by passing an incorrectly formatted filesystem path to a Windows API.

## Fixed: "unable to find executable" in bunx

A bug where running `bunx <package>` sometimes returned `error: unable to find executable` when it definitely should have been able to find the executable has been fixed.

The bug was caused by a cache invalidation bug in `bunx`. `bunx` was checking the `package.json` of the target package instead of the generated package.json that adds the target package as a dependency. The filesystem's creation time for that file may come from the original time the package was published to npm, which means it would virtually always invalidate the executable. Separately, there was another bug where `bunx` would check the creation time of the `package.json` _twice_, first when trying to use the cached verison and a second time after newly installing the package. Checking that second time is unnecessary because it was newly created.

## Fixed: "Failed to install" error with Git dependencies

A bug where `bun install` would fail to clone or checkout a git repository with a dependency that was a Git repository has been fixed. This bug was caused by assuming the current working directory of the target package continued to have a valid file descriptor when the `git clone` or `git checkout` command was run. We switched it to use an absolute filesystem path instead, via the `-C` flag in `git`.

Thanks to [@gvilums](https://github.com/gvilums) for fixing this issue.

## Fixed: Spurious error when pressing CTRL+C in `bun init`

An error that would occur when pressing CTRL+C in `bun init` has been fixed.

## Fixed: `npm install -g bun` should work now on Windows

Sorry. Please let us know if you're still having issues with `npm install -g bun` on Windows.

### Runtime improvements

## Truncated source code previews in error traces

When a top-level exception is thrown, Bun prints relevant source code to help you debug the error faster.

Normally, it looks like this:

```js
1 | function oops() {
2 |   throw new Error("Woopsie woops!");
            ^
error: Woopsie woops!
      at oops (woopsie.js:2:9)
      at woopsie.js:5:1
```

However, what happens if the error is in a minified file? It would look something like this:

```js
1 | function oops() {
2 | var h=1,t=2,m=3,x=4,m={o:{n:{t:{a:[{n: a}, {b: "uffalos"},() => {throw new Error("Woopsie woops!")}]}}}},j=q.u.e.r.y[0];such();minified();

error: Woopsie woops!
      at oops (woopsie.js:2:9)
      at woopsie.js:5:1
```

Some libraries publish minified source code. Most minifiers try to pack as much code as possible on a single line to reduce the byte count over the wire. Trying to print that to your terminal is...messy.

Previously, Bun would just dump the nearest 4 line(s) to your terminal. Now, we truncate the source code up to 1024 bytes per line. If the code is longer than 512 bytes, we also hide the divot `^` character since that ends up being quite a lot of whitespace. This makes it easier to read the error message.

## JavaScriptCore upgrade

We've upgraded JavaScriptCore to the latest version, and there are a handful of performance and memory improvements in it.

- Inline caching of function calls has been redesigned, reducing memory usage thanks to [@Constellation](https://github.com/Constellation) - [#65c8acc46999](https://github.com/WebKit/WebKit/commit/65c8acc4699947d9a9b6326b9672a2fca5804a8c) [#d0345d69220e](https://github.com/WebKit/WebKit/commit/d0345d69220e43945f9b9632378eab88cb50e1da)
- Error location tracking has been redesigned to reduce memory usage, thanks to [@MenloDorian](https://github.com/MenloDorian): [#22880](https://github.com/WebKit/WebKit/pull/22880)
- Case-insensitive `RegExp` with backreferences including non-ascii characters are now JIT compiled, thanks to [@msaboff](https://github.com/msaboff): [#26391](https://github.com/WebKit/WebKit/pull/26391)
- String.prototype.includes, String.prototype.replace adapts how it searches based on the input, thanks to [@Constellation](https://github.com/Constellation): [#bacdbdaaf182](https://github.com/WebKit/WebKit/commit/bacdbdaaf1824b08dc7ad35035d5d8358be623c5)
- Multiplying strings by numbers gets 18% faster, thanks to [@Constellation](https://github.com/Constellation) - [#57a7762336ee](https://github.com/WebKit/WebKit/commit/57a7762336eea989764e026e58f1e3a5e845f652)
- RegExp /u flags now respects atomicity of surrogate pairs, thanks to [@msaboff](https://github.com/msaboff) - [#584a9a820ab2](https://github.com/WebKit/WebKit/commit/584a9a820ab2d2408314858daaccc8a9f01f6c56)
- `Float32Array` access gets 9% faster, thanks to [@Constellation](https://github.com/Constellation) - [#eebb374f2bcd](https://github.com/WebKit/WebKit/commit/eebb374f2bcd1ebf9c6b5740f839dcaa3e2af3a4)
- Checking if two strings are equal gets 1% faster when one string is ascii and the other has non-ascii, thanks to [@Constellation](https://github.com/Constellation): [#bacdbdaaf1](https://github.com/oven-sh/WebKit/commit/bacdbdaaf1824b08dc7ad35035d5d8358be623c5)

Bugfixes:

- A bug with the source location of member expressions with multiple `new` keywords has been fixed, thanks to [@alexey](https://github.com/alexey) - [#27567fb2a9f3](https://github.com/WebKit/WebKit/commit/27567fb2a9f316d9bc6a1b75d2b94b02731756c6)

## Fixed: TOML parsing bug with escape sequences and Windows filesystem paths

A bug where Bun's TOML parser did not properly handle escape sequences and Windows filesystem paths has been fixed and we've added more tests to prevent this from happening again.

## Fixed: Crash when `node:vm` throws an exception across global objects

A crash that could occur when code run in a `node:vm` context threw an exception to be handled by the main global object has been fixed.

This crash was cuased by assuming the global object was the same one as the main global object.

## Fixed: `process.dlopen` now supports `file:` URLs

`process.dlopen` in Bun now supports loading shared libraries from `file:` URLs. `file:` URLs passed to `process.dlopen` are automatically translated to a filesystem path.

## Fixed: ResolveMessage.message and BuildMessage.message are now writable

When trying to use ESLint in Bun, sometimes it would throw an error saying "Attempt to write to read-only property 'message'". This was caused by the `message` property being read-only in the `ResolveMessage` and `BuildMessage` classes in Bun. This isn't a great fix, `BuildMessage` and `ResolveMessage` should really extend `Error` instead of being their own classes - but it's a fix nonetheless.

### Bun Shell improvements

Bun Shell powers package.json scripts in `bun run` and lifecycle scripts in `bun install` on Windows.

## Subshells

Bun Shell now supports subshells.

```js
import { $ } from "bun";

await $`echo hey $(echo hi)`;
// > hey hi
```

Subshells are frequently used to compose multiple commands into a single command.

On Windows, this also means `bun run` package.json scripts now support subshells.

Thanks to [@zackradisic](https://github.com/zackradisic) for implementing this.

## Positional arguments with $0 $1 $2 through $9

Bun Shell now supports positional arguments with `$0` `$1` `$2` through `$9`.

Running the following script:

```js
import { $ } from "bun";

await $`echo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9`;
```

From Bun Shell will print:

```sh
> bun ./script.ts hello world foo bar baz
bun ./script.ts hello world foo bar baz
```

Previously, this would have printed:

```sh
$ bun ./script.ts hello world foo bar baz
> $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
```

Thanks to [@nektro](https://github.com/nektro) for implementing this.

## Thank you to 8 contributors!

- [@cirospaciari](https://github.com/cirospaciari)
- [@dylan-conway](https://github.com/dylan-conway)
- [@gvilums](https://github.com/gvilums)
- [@Jarred-Sumner](https://github.com/Jarred-Sumner)
- [@mangs](https://github.com/mangs)
- [@nektro](https://github.com/nektro)
- [@paperclover](https://github.com/paperclover)
- [@zackradisic](https://github.com/zackradisic)
