esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Upgrading with yarn fails...

Open bbak opened this issue 8 months ago • 3 comments

Log-Entry:


# This file contains the result of Yarn building a package (esbuild@npm:0.25.3)
# Script name: postinstall

node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: C:\Program Files\nodejs\node.exe C:\Users\.....\node_modules\esbuild\bin\esbuild --version
node:child_process:921

    throw err;

    ^



<ref *1> Error: spawnSync C:\Users\...\node_modules\@esbuild\win32-x64\esbuild.exe EPERM

    at Object.spawnSync (node:internal/child_process:1120:20)

    at spawnSync (node:child_process:868:24)

    at Object.execFileSync (node:child_process:911:15)

    at Object.<anonymous> (C:\Users\...\node_modules\esbuild\bin\esbuild:221:28)

    at Module._compile (node:internal/modules/cjs/loader:1734:14)

    at Object..js (node:internal/modules/cjs/loader:1899:10)

    at Module.load (node:internal/modules/cjs/loader:1469:32)

    at Function._load (node:internal/modules/cjs/loader:1286:12)

    at TracingChannel.traceSync (node:diagnostics_channel:322:14)

    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) {

  errno: -4048,

  code: 'EPERM',

  syscall: 'spawnSync C:\\Users\\...\\node_modules\\@esbuild\\win32-x64\\esbuild.exe',

  path: 'C:\\Users\\...\\node_modules\\@esbuild\\win32-x64\\esbuild.exe',

  spawnargs: [ '--version' ],

  error: [Circular *1],

  status: null,

  signal: null,

  output: null,

  pid: 0,

  stdout: undefined,

  stderr: undefined

}



Node.js v23.11.0


    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:882:11)
    at Object.execFileSync (node:child_process:918:15)
    at validateBinaryVersion (C:\Users\...\node_modules\esbuild\install.js:101:28)
    at C:\Users\...\node_modules\esbuild\install.js:283:5 {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(0) [Uint8Array] [],
    Buffer(1262) [Uint8Array] [
      110, 111, 100, 101,  58,  99, 104, 105, 108, 100,  95, 112,
      114, 111,  99, 101, 115, 115,  58,  57,  50,  49,  13,  10,
       32,  32,  32,  32, 116, 104, 114, 111, 119,  32, 101, 114,
      114,  59,  13,  10,  32,  32,  32,  32,  94,  13,  10,  13,
       10,  60, 114, 101, 102,  32,  42,  49,  62,  32,  69, 114,
      114, 111, 114,  58,  32, 115, 112,  97, 119, 110,  83, 121,
      110,  99,  32,  67,  58,  92,  85, 115, 101, 114, 115,  92,
       73,  53,  53,  53,  52,  53,  52,  92,  79, 110, 101,  68,
      114, 105, 118, 101,
      ... 1162 more items
    ]
  ],
  pid: 39144,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(1262) [Uint8Array] [
    110, 111, 100, 101,  58,  99, 104, 105, 108, 100,  95, 112,
    114, 111,  99, 101, 115, 115,  58,  57,  50,  49,  13,  10,
     32,  32,  32,  32, 116, 104, 114, 111, 119,  32, 101, 114,
    114,  59,  13,  10,  32,  32,  32,  32,  94,  13,  10,  13,
     10,  60, 114, 101, 102,  32,  42,  49,  62,  32,  69, 114,
    114, 111, 114,  58,  32, 115, 112,  97, 119, 110,  83, 121,
    110,  99,  32,  67,  58,  92,  85, 115, 101, 114, 115,  92,
     73,  53,  53,  53,  52,  53,  52,  92,  79, 110, 101,  68,
    114, 105, 118, 101,
    ... 1162 more items
  ]
}

Node.js v23.11.0


bbak avatar Apr 23 '25 07:04 bbak

esbuild.exe EPERM

EPERM is a permission problem, and likely indicates that something is wrong with your specific machine configuration. You have to debug and fix this for yourself.

evanw avatar Apr 23 '25 14:04 evanw

I've been seeing similar EPERM errors on Windows specifically since the 0.25.0 release. For now, I've been pinning to 0.24.2, which is functional, until I have bandwidth to debug. Did something change related to permissions required with that release @evanw?

jvillanuevabt avatar Apr 23 '25 21:04 jvillanuevabt

I don't believe the installer has been changed in a long time.

Unfortunately I don't have a Windows machine and I'm also unfamiliar with Yarn, so I'm unable to debug this for myself. I'll accept a patch for a fix if someone can debug it and provide a fix along with a failing test case.

evanw avatar Apr 23 '25 23:04 evanw

I am having issues with this using plain old NPM. I note that 0.25.5 works fine on my machine, but 0.25.6 has issues. At the time of writing 0.25.6 is very new (less than 1 day old, with "zero" downloads) whereas 0.25.5 is relatively well-established.

version downloads release
0.25.6 0 13 hours ago
0.25.5 9,488,941 a month ago

I checked the Windows Defender logs and it looks like Microsoft Defender Exploit Guard is blocking the latest build.

Microsoft Defender Exploit Guard has blocked an operation that is not allowed by your IT administrator.
 For more information please contact your IT administrator.
 	ID: <REDACTED>
 	Detection time: 2025-07-08T06:35:51.571Z
 	User: <REDACTED>
 	Path: D:\projects\test-thing\tmp\0.25.6\package\esbuild.exe
 	Process Name: C:\Program Files\Git\usr\bin\bash.exe
 	Target Commandline: 
 	Parent Commandline: "C:\Program Files\Git\bin\..\usr\bin\bash.exe" -i -l
 	Involved File: 
 	Inheritance Flags: 0x00000000
 	Security intelligence Version: 1.431.467.0
 	Engine Version: 1.1.25050.6
 	Product Version: 4.18.25050.5

I'm not sure what you as a developer can do about this other than document it and maybe talk to Microsoft about why new versions of esbuild in particular get blocked like this.

jetwiwo avatar Jul 08 '25 06:07 jetwiwo

@jetwiwo FYI esbuild 0.25.6 works fine on my Windows setup.

It seems you're running esbuild from bash.exe from git, and Windows Defender is blocking bash.exe from executing another exe.

Executing windows programs from Git Bash is generally a bad idea since they (programs) will be confused when detecting environments (am i on Linux or Windows?). I'd recommend you use cmd.exe or powershell instead.

hyrious avatar Jul 08 '25 07:07 hyrious

FYI esbuild 0.25.6 works fine on my Windows setup.

Yeah it works fine on github actions as well. Windows isn't the issue per se; it's probably only an issue on enterprise/corporate windows which tend to have stricter policies. I'm sure it'll work on my machine in a few days once Microsoft updates some signature somewhere that allows this particular version. I'm also sure some future version (probably every future version) will have the same issue for a few days after release.

It seems you're running esbuild from bash.exe from git, and Windows Defender is blocking bash.exe from executing another exe.

It blocks any parent process (e.g. explorer.exe, cmd.exe) if I try there, bash is just my shell of choice. It also doesn't block bash from executing any of the 100s of executables I run with it on the daily. The reason for the block is esbuild.exe, not bash.

Executing windows programs from Git Bash is generally a bad idea since they (programs) will be confused when detecting environments (am i on Linux or Windows?). I'd recommend you use cmd.exe or powershell instead.

MSYS actually has an excellent compatibility layer and works just fine with 99% of anything I'd ever want to run, including every version of esbuild except this one. cmd and powershell are not suitable replacements. We're going to have to agree to disagree on this one.

jetwiwo avatar Jul 08 '25 09:07 jetwiwo

FYI the file is no longer blocked as of today.

jetwiwo avatar Jul 09 '25 00:07 jetwiwo

Ok, thanks. In that case I'm closing this as it's not a bug with esbuild.

evanw avatar Aug 12 '25 23:08 evanw

Ok, thanks. In that case I'm closing this as it's not a bug with esbuild.

Agreed. We noticed this issue happens with new releases of some other packages as well so it's an issue with some Microsoft Defender configurations running new software, not esbuild as far as I can tell.

jetwiwo avatar Aug 14 '25 01:08 jetwiwo