continue icon indicating copy to clipboard operation
continue copied to clipboard

DEV: "No loader is configured for ".bak" files:" exception when running install-dependencies.sh twice

Open KoStard opened this issue 9 months ago • 1 comments

Before submitting your bug report

Relevant environment info

- OS: MacOS 14.4.1 (23E224)
- Continue: git clone
- IDE:VSCode

Description

When setting up the local dev environment, if you run the install-dependencies.sh command twice, you get an error.

Manual mitigation

cd binary/
rm -rf node_modules/
npm install
npm run build

To reproduce

git clone https://github.com/continuedev/continue
./install-dependencies.sh
./install-dependencies.sh

or

git clone https://github.com/continuedev/continue
./install-dependencies.sh
cd binary/
npm install
npm run build

Log output

[info] Building with esbuild...
✘ [ERROR] No loader is configured for ".bak" files: node_modules/win-ca/lib/crypt32-x64.node.bak

    node_modules/win-ca/lib/n-api.js:3:18:
      3 │ crypt32 = require("./crypt32-" + process.arch);
        ╵                   ~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".bak" files: node_modules/win-ca/lib/crypt32-ia32.node.bak

    node_modules/win-ca/lib/n-api.js:3:18:
      3 │ crypt32 = require("./crypt32-" + process.arch);
        ╵                   ~~~~~~~~~~~~

/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1651
  let error = new Error(text);
              ^

Error: Build failed with 2 errors:
node_modules/win-ca/lib/n-api.js:3:18: ERROR: No loader is configured for ".bak" files: node_modules/win-ca/lib/crypt32-ia32.node.bak
node_modules/win-ca/lib/n-api.js:3:18: ERROR: No loader is configured for ".bak" files: node_modules/win-ca/lib/crypt32-x64.node.bak
    at failureErrorWithLog (/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1059:25
    at /Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1004:52
    at buildResponseToResult (/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1057:7)
    at /Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> (/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/Users/kostard/personal/continue/binary/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v20.11.0

KoStard avatar May 11 '24 20:05 KoStard

Hello!

I have narrowed down generation of .bak files to the cross platform binary builds for windows here. The following pkg invocations cause the issue:

  • npx pkg --no-bytecode --public-packages "*" --public pkgJson/win32-x64 --out-path bin/win32-x64
  • npx pkg --no-bytecode --public-packages "*" --public pkgJson/win32-arm64 --out-path bin/win32-arm64

After these calls to pkg, some .node files will be copied into .node.bak files due to the following code in vercel/pkg:

  // prebuild-install will overwrite the target .node file, so take a backup
  if (!fs.existsSync(`${nodeFile}.bak`)) {
    fs.copyFileSync(nodeFile, `${nodeFile}.bak`);
  }

A subsequent run of the build script will fail when invoking esbuild here.

A possible solution would be to delete the problem .node.bak files before invoking esbuild. I have created a pull request with the changes here: https://github.com/continuedev/continue/pull/1287

fernandosanchezjr avatar May 15 '24 21:05 fernandosanchezjr

I think this is solved now. I don't seem to have the same issue anymore.

KoStard avatar Jun 19 '24 20:06 KoStard