bun icon indicating copy to clipboard operation
bun copied to clipboard

bun --filter gives (error: ENOENT)

Open birkskyum opened this issue 1 year ago • 14 comments

What version of Bun is running?

1.1.10-canary.1+6566b8a6d

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Add workspaces to a package.json and run bun --filter '*' dev or a specific package in the filter

What is the expected behavior?

that the dev script would be executed in all packages.

What do you see instead?

➜ bun --filter 'isomorphic' run dev error: ENOENT

Additional information

No response

birkskyum avatar May 23 '24 11:05 birkskyum

I can't repro this anymore

birkskyum avatar May 30 '24 13:05 birkskyum

Did you upgrade since this happened, we are now getting this as well? On latest version (1.1.12)

dbrxnds avatar Jun 04 '24 08:06 dbrxnds

@dbrxnds do you have a folder named "dev" by chance?

Jarred-Sumner avatar Jun 04 '24 08:06 Jarred-Sumner

@Jarred-Sumner We do not. And I get it with bun --filter orderpicker typecheck (orderpicker is our main application workspace) as well

dbrxnds avatar Jun 04 '24 08:06 dbrxnds

@dbrxnds if you're on Linux by chance, do you think you could paste the output of

sudo perf trace $(which bun) --filter orderpicker typecheck

That will tell us what specific path Bun is searching through and seeing ENOENT. Then that will get us closer to where the bug is ocurring.

Jarred-Sumner avatar Jun 04 '24 08:06 Jarred-Sumner

@Jarred-Sumner, is this what you are expecting? https://gist.github.com/dbrxnds/41bd83a5a66bb70cb86cf2e05653d296

dbrxnds avatar Jun 04 '24 08:06 dbrxnds

@dbrxnds yes but sadly not as helpful as I thought it'd be

Jarred-Sumner avatar Jun 04 '24 08:06 Jarred-Sumner

@Jarred-Sumner Unfortunate, let me know if I can do / share anything else

dbrxnds avatar Jun 04 '24 08:06 dbrxnds

I believe I hit this error in the first place by providing some syntax not expected by bun (initial slash)

"workspaces": [
    "/packages/*"
  ],

If I use the syntax below (provided in bun docs), things work as expected

"workspaces": [
  "packages/*"
],

@dbrxnds , how do you define your workspaces in package.json?

birkskyum avatar Jun 04 '24 08:06 birkskyum

Interesting @birkskyum, here's ours:

"workspaces": [
    "apps/*",
    "packages/*",
    "serverless",
    "serverless/layers/*",
    "serverless/services/*",
    "scripts"
  ],

dbrxnds avatar Jun 04 '24 09:06 dbrxnds

Hi @birkskyum, your comment made me check if I could get it working by removing/changing workspaces as well.

In our case it seems to happen due to a workspace being nested. @Jarred-Sumner

Doesn't work:

  "workspaces": [
    "apps/*",
    "packages/*",
    "serverless/services/*",
    "scripts"
  ],

Works:

  "workspaces": [
    "apps/*",
    "packages/*",
    "scripts"
  ],

dbrxnds avatar Jun 05 '24 10:06 dbrxnds

I get same error when running bun --filter inside bun docker image CMD e.g:

FROM oven/bun:slim 
WORKDIR /app
COPY .  .
RUN bun install --frozen-lockfile --production
CMD ["bun", "--filter", "./app/web", "start" ]

Error running image: error: ENOENT

package.json

{
  "name": "app",
  "private": true,
  "scripts": {},
  "workspaces": [
    "packages/*",
    "apps/*"
  ],
  "dependencies": {},
  "devDependencies": {
    "@biomejs/biome": "1.9.4"
  }
}

arrudaricardo avatar Oct 24 '24 19:10 arrudaricardo

I can confirm this also started happening randomly in my docker build. Same type of command, also with workspaces.

I also tried checking out the last successful commit of my code that build, together with the sha of the last bun docker image that built successfully, but that does not work either. Not quite sure what's going on here.

Update I just worked around the issue by using --cwd instead and running the scripts that --filter would hit, and it works just fine. So there is definitely something strange with --filter that affects certain environments.

LudvigHz avatar Oct 24 '24 20:10 LudvigHz

In my case I was seeing this when adding a new workspace with a directory name that was camel case, when I renamed the new module to be all lower case the issue went away

andyridge289 avatar Dec 17 '24 15:12 andyridge289

I was having this exact issue then a team member figured it out.

EVERY package must have the script.

For instance: bun --filter "./packages/*" lint required that all the packages located in './packages/*' have a script called lint, in order for the filter to pass successfully.

jguillen1984 avatar Mar 18 '25 15:03 jguillen1984

So my script is noo preset in every workspace. The interresting things is that it works fine on Mac arm64, but it fails on linux/amd64

lordphnx avatar Apr 18 '25 14:04 lordphnx

Same here any usage of --filter works fine locally (MacOS Sonoma aarch64) but ENOENT on gh actions (Ubuntu LTS)

"workspaces": [
  "packages/**",
  "apps/**"
]

louisdutton avatar May 16 '25 18:05 louisdutton

I did find a vague interplay between --omit=dev, which causes (recursively) a peer dependency not to be installed. Which solves the issue in some of my workspaces, but not all

lordphnx avatar May 21 '25 09:05 lordphnx