bun icon indicating copy to clipboard operation
bun copied to clipboard

Bun errors if main script is empty `Failed to run "test.js" due to error InvalidExe`

Open apacheli opened this issue 3 years ago • 4 comments

Version

0.1.6

Platform

Linux helipad 5.10.16.3-microsoft-standard-WSL2 (hashtag)1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

What steps will reproduce the bug?

  • Create a new a script and leave it empty
  • Run the script
  • Encounter the error

How often does it reproduce? Is there a required condition?

This error will always occur if the main script is empty.

What is the expected behavior?

Bun should not error if the main script is empty.

What do you see instead?

error: Failed to run "test.js" due to error InvalidExe

Additional information

If you import an empty file from another file, it does not error. This error only occurs if the main script is empty.

bun run hello.js

hello.js

import "./empty.tsx";

empty.tsx


  • Running VSCodium (Visual Studio Code)
  • Windows 10 Home using WSL

apacheli avatar Aug 02 '22 07:08 apacheli

Could you upgrade to v0.1.8 and give it another try? This seems to be fixed. Close for now, feel free to reopen if the bug still exits :)

zhuzilin avatar Aug 15 '22 07:08 zhuzilin

I have upgrade to v0.1.10 and it seems like this issue has reappeared 😆

image

apacheli avatar Aug 25 '22 08:08 apacheli

~~I'm not sure if this is related or a separate issue. But I'm geetting a very similar error trying to run Purescript.~~

Operating System: Archlinux Bun version: 0.1.10 Steps to reproduce:

  1. bun install purescript
  2. bun run purs

Failed to run "purs" due to error InvalidExe

EDIT: Solved this. Purescript has a postinstall script, which didn't get run. I manually ran it, and now it works. :)

DanielPower avatar Aug 25 '22 21:08 DanielPower

On bun v0.1.10, fresh installed on WSL/Ubuntu. Some commands don't seem to be executing correctly.

  1. bun run package.json yields error: Failed to run "package.json" due to error InvalidExe
  2. bun upgrade, bun install and bun c react . returns immediately without any messages in the console.
  3. bun dev inside a react project directory states that it started a server, but closes immediately without any error message.

EDIT: found the other issue involving wsl/ubuntu and downgraded to 0.1.8

kacogg5 avatar Sep 07 '22 16:09 kacogg5

Reproducible example:

// index.ts
console.log(1)
bun build --compile index.ts --outfile asd # does not have .js
bun run asd # works
bun build index.ts --outfile asd # without compile
bun run asd
# error: Failed to run "asd" due to error InvalidExe

arthurfiorette avatar Sep 18 '23 02:09 arthurfiorette

I have the same error executing bunx my-package and is just a file in bash (.sh). And with npx works fine...

aralroca avatar Sep 29 '23 11:09 aralroca

We've since fixed this issue. As of Bun v1.0.7, this error no longer occurs. If you can still run into this problem after upgrading, please feel free to re-open this issue.

Electroid avatar Oct 25 '23 18:10 Electroid

Been having this issue for about a week now, I've been trying ElysiaJS for a month, all has been great after I discovered that Bun alone will not run Prisma scripts, I needed Node to be installed too. Anyway, bunx prisma db push gives me the error "Failed to run "prisma" due to error InvalidExe",

I'm on Bun 1.0.13, Prisma 5.6.0, Elysia 0.7.21, Windows 11 WSL2 on a Surface Laptop 2

cholasimmons avatar Nov 19 '23 02:11 cholasimmons

We've since fixed this issue. As of Bun v1.0.7, this error no longer occurs. If you can still run into this problem after upgrading, please feel free to re-open this issue.

@Electroid I still have this bunx InvalidExe error in bun 1.0.21, to execute a simple bin with .sh extension...

the only commands in this bash: echo, read, mkdir, bun install. Can be problem of bun install inside this bash? Is it possible to try bunx locally without do releases to indentify where is the error on the bash? With npx works well... 😅

aralroca avatar Jan 02 '24 17:01 aralroca

in the end, I solved it by changing the bin from .sh to .cjs with #!/usr/bin/env node shebang

aralroca avatar Jan 02 '24 21:01 aralroca