Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running arm64 REH build exits with MODULE_NOT_FOUND error #5775

Open
timtmok opened this issue Dec 17, 2024 · 4 comments
Open

Running arm64 REH build exits with MODULE_NOT_FOUND error #5775

timtmok opened this issue Dec 17, 2024 · 4 comments
Labels
area: builds Issues related to Builds category. area: remote host bug Something isn't working

Comments

@timtmok
Copy link
Contributor

timtmok commented Dec 17, 2024

System details:

Positron and OS details:

main on Linux arm64 and Mac

Interpreter details:

n/a

Describe the issue:

I haven't been able to try this on Linux x86_64 but a local REH build fails to run from what looks like import problems from the 1.95.0 merge.

../vscode-reh-web-darwin-arm64/bin/positron-server --version
node:internal/modules/cjs/loader:1225
  const err = new Error(message);
              ^

Error: Cannot find module '../package.json'
Require stack:
- /Users/tmok/source/vscode-reh-web-darwin-arm64/out/server-main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at file:///Users/tmok/source/vscode-reh-web-darwin-arm64/out/server-main.js:59132:12
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/tmok/source/vscode-reh-web-darwin-arm64/out/server-main.js'
  ]
}

Node.js v20.18.0
(base) 

Steps to reproduce the issue:

  1. Build REH. (I used npm run gulp vscode-reh-web-darwin-arm64 and npm run vscode-reh-web-linux-arm64)
  2. Run positron-server

Expected or desired behavior:

No errors about finding modules

Were there any error messages in the UI, Output panel, or Developer Tools console?

@timtmok
Copy link
Contributor Author

timtmok commented Dec 17, 2024

I just ran this in Docker while emulating x86_64 and it worked.

#8 [4/4] RUN /vscode-reh-linux-x64/bin/positron-server --version
#8 1.045 Positron: 2025.01.0 build 95
#8 1.045 Positron SHA: 1df88e1c4acc0739ccf1b51a85ea5ff10058ea79
#8 1.045 Code OSS: 1.95.0
#8 1.045 Arch: x64
#8 DONE 1.1s

@nstrayer nstrayer added bug Something isn't working area: builds Issues related to Builds category. labels Dec 17, 2024
@jmcphers
Copy link
Collaborator

This is where the error is being raised, from server-main.js:

var pkgObj = { BUILD_INSERT_PACKAGE_CONFIGURATION: "BUILD_INSERT_PACKAGE_CONFIGURATION" };
if (pkgObj["BUILD_INSERT_PACKAGE_CONFIGURATION"]) {
  pkgObj = require3("../package.json");
}

This source is compiled from bootstrap-meta here:

let pkgObj = { BUILD_INSERT_PACKAGE_CONFIGURATION: 'BUILD_INSERT_PACKAGE_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD
if (pkgObj['BUILD_INSERT_PACKAGE_CONFIGURATION']) {
pkgObj = require('../package.json'); // Running out of sources
}

@jmcphers
Copy link
Collaborator

There's build tooling that is supposed to insert the package.json contents inline.

export function inlineMeta(result: NodeJS.ReadWriteStream, ctx: IInlineMetaContext): NodeJS.ReadWriteStream {
return result.pipe(es.through(function (file: File) {
if (matchesFile(file, ctx)) {
let content = file.contents.toString();
let markerFound = false;
const packageMarker = `${packageJsonMarkerId}:"${packageJsonMarkerId}"`; // this needs to be the format after esbuild has processed the file (e.g. double quotes)
if (content.includes(packageMarker)) {
content = content.replace(packageMarker, JSON.stringify(JSON.parse(ctx.packageJsonFn())).slice(1, -1) /* trim braces */);
markerFound = true;
}

However, it isn't running or isn't working, as the working version also has this placeholder. The difference between the working version (Linux) and the broken one (macOS) is the presence of package.json in the build folder.

@jmcphers jmcphers changed the title Running REH build exits with MODULE_NOT_FOUND error Running arm64 REH build exits with MODULE_NOT_FOUND error Dec 18, 2024
@juliasilge juliasilge added this to the Release Candidate milestone Jan 6, 2025
jmcphers added a commit that referenced this issue Jan 17, 2025
This change addresses an issue in which Positron Server doesn't start
due to an error like this one:

```
(node:11206) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/ubuntu/vscode-reh-web-linux-x64/out/server-main.js:26
export function __extends(d, b) {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile 
```

The problem was caused by an incompletely merged line in the initial
1.95 merge, which caused a cascade of silent failures that led to
`package.json` being omitted from the `reh-web` bundle, which led to the
above failure since `package.json` was responsible for setting `"type":
"module"` as noted above. The fix is just to update the line to match
what it was before the merge:


https://github.com/posit-dev/positron/blob/fa567b23598d7f91eab1f2aa182ae8b1e8b50099/build/gulpfile.reh.js#L378-L383

Addresses, coincidentally,
#5775, which is where this
error was first spotted.

After the change, it ought to be possible to run `./positron-server`
without error. E.g.:

```
./positron-server --version
Positron: 2025.01.1 build 4
Positron SHA: 9f520e6
Code OSS: 1.96.0
Arch: arm64
```
jmcphers added a commit that referenced this issue Jan 17, 2025
This change addresses an issue in which Positron Server doesn't start
due to an error like this one:

```
(node:11206) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/ubuntu/vscode-reh-web-linux-x64/out/server-main.js:26
export function __extends(d, b) {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile 
```

The problem was caused by an incompletely merged line in the initial
1.95 merge, which caused a cascade of silent failures that led to
`package.json` being omitted from the `reh-web` bundle, which led to the
above failure since `package.json` was responsible for setting `"type":
"module"` as noted above. The fix is just to update the line to match
what it was before the merge:


https://github.com/posit-dev/positron/blob/fa567b23598d7f91eab1f2aa182ae8b1e8b50099/build/gulpfile.reh.js#L378-L383

Addresses, coincidentally,
#5775, which is where this
error was first spotted.

After the change, it ought to be possible to run `./positron-server`
without error. E.g.:

```
./positron-server --version
Positron: 2025.01.1 build 4
Positron SHA: 9f520e6
Code OSS: 1.96.0
Arch: arm64
```
jmcphers added a commit that referenced this issue Jan 17, 2025
This change addresses an issue in which Positron Server doesn't start
due to an error like this one:

```
(node:11206) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/ubuntu/vscode-reh-web-linux-x64/out/server-main.js:26
export function __extends(d, b) {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile 
```

The problem was caused by an incompletely merged line in the initial
1.95 merge, which caused a cascade of silent failures that led to
`package.json` being omitted from the `reh-web` bundle, which led to the
above failure since `package.json` was responsible for setting `"type":
"module"` as noted above. The fix is just to update the line to match
what it was before the merge:


https://github.com/posit-dev/positron/blob/fa567b23598d7f91eab1f2aa182ae8b1e8b50099/build/gulpfile.reh.js#L378-L383

Addresses, coincidentally,
#5775, which is where this
error was first spotted.

After the change, it ought to be possible to run `./positron-server`
without error. E.g.:

```
./positron-server --version
Positron: 2025.01.1 build 4
Positron SHA: 9f520e6
Code OSS: 1.96.0
Arch: arm64
```
@jmcphers
Copy link
Collaborator

Note that this fix went into the 2025.01 branch so should be verified on the next 2025.01 build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: builds Issues related to Builds category. area: remote host bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants