data icon indicating copy to clipboard operation
data copied to clipboard

Executing codemod on Linux

Open yatsura opened this issue 10 months ago • 1 comments

Hi,

I'm encountering an issue when trying to run the Ember Data codemod on Linux using pnpx:

pnpx @ember-data/codemods apply legacy-compat-builders ./app/**/*.{js,ts}

The command fails with an "Exec format error". Upon investigation, I found that the executable file (node_modules/@ember-data/codemods/codemods) is a Mach-O 64-bit arm64 executable, which is incompatible with Linux.

Looking at the package.json file within @ember-data/codemods, the bin entry points to this codemods file, and the build script seems to use Bun with the --target node flag:

"bin": {
  "codemods": "codemods"
},
"scripts": {
  "build:cli": "bun build bin/codemods.ts --compile --target node --outfile codemods --sourcemap",
  // ... 
}

I've also tried running the codemod directly with Node.js:

node node_modules/@ember-data/codemods/codemods apply legacy-compat-builders ./app/**/*.{js,ts}

This resulted in a SyntaxError: Invalid or unexpected token, indicating that the file is not standard JavaScript.

Additionally, I attempted to run it using bunx on Linux (Bun version 1.2.12):

bunx @ember-data/codemods apply legacy-compat-builders ./app/**/*.{js,ts}

My system is running Ubuntu and I am using Node.js v22.13. I am managing my project dependencies with pnpm.

It appears that the Bun build process, even with the --target node flag, is producing an executable that is not compatible with Linux and is being misinterpreted by pnpx as a Mach-O binary.

Could you please investigate this issue?

yatsura avatar May 08 '25 16:05 yatsura

we need to fix it to use the strategy here https://runspired.com/2025/01/25/npx-executables-with-bun.html

runspired avatar May 08 '25 20:05 runspired