fret icon indicating copy to clipboard operation
fret copied to clipboard

Unable to build FRET

Open sand7000 opened this issue 2 years ago • 2 comments

I am following the instructions to build the executable here:

https://github.com/NASA-SW-VnV/fret/blob/master/fret-electron/docs/_media/installingFRET/buildingExecutables.md

I tried this in both the provided docker and in my own ubuntu env and got the same erroneous results. I also tried with both the master branch and with the v2.9.0 tag.

The first error is simple:

E: Package 'libasound2' has no installation candidate

so I changed Dockerfile:

-FROM ubuntu:latest
+FROM ubuntu:20.04

But then I get the error:

A JavaScript error occurred in the main process Uncaught Exception: /home/fret/fret/fret-electron/app/index.js:33 import React from 'react'; ^^^^^^ SyntaxError: Cannot use import statement outside a module

So I changed generate_executable_Linux.sh:

+# Ensure package.json specifies that we're using ES modules
+if grep -q '"type": "module"' package.json; then
+    echo 'Module type already specified in package.json'
+else
+    sed -i '/"name":/a \  "type": "module",' package.json
+    echo 'Added "type": "module" to package.json'
+fi

But then I get the error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/fret/fret/fret-electron/app/index.js from /home/fret/fret/fret-electron/node_modules/electron/dist/resources/default_app.asar/main.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs

So I again changed generate_executable_Linux.sh:

+# Rename index.js to index.cjs to ensure it's treated as a CommonJS module
+mv /home/fret/fret/fret-electron/app/index.js /home/fret/fret/fret-electron/app/index.cjs

At this point I get the error:

Unable to find Electron app at /home/fret/fret/fret-electron/app Cannot find module '/home/fret/fret/fret-electron/app/main.prod.js'

So I again changed generate_executable_Linux.sh:

+# Ensure the main entry in package.json points to the correct file
+if grep -q '"main":' package.json; then
+    # If the main entry exists, update it
+    sed -i 's/"main": ".*"/"main": "index.cjs"/' package.json
+else
+    # If the main entry does not exist, add it after the first opening brace
+    sed -i '1a\  "main": "index.cjs",' package.json
+fi

I was then able to complete the build and generate the tar file but I get the runtime error:

A JavaScript error occurred in the main process Uncaught Exception: /home/ubuntu1/FRET-linux-x64/resources/app/index.cjs:33 import React from 'react'; ^^^^^^

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1185:20) at Module._compile (node:internal/modules/cjs/loader:1227:27) at Object..js (node:internal/modules/cjs/loader:1326:10) at Module.load (node:internal/modules/cjs/loader:1126:32) at node:internal/modules/cjs/loader:967:12 at Function._load (node:electron/js2c/node_init:2:13357) at node:electron/js2c/browser_init:2:121197 at node:electron/js2c/browser_init:2:121400 at node:electron/js2c/browser_init:2:121404 [1746:1009/141742.118004:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.DBus.StartServiceByName: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

So I guess my attempts to patch this have failed. Do you have any advice for me?

sand7000 avatar Oct 09 '24 14:10 sand7000

Hi @sand7000 ,

Thanks for trying out FRET and reporting this issue. A fix for it will be provided with our next release, coming soon. In the meantime, to resolve it for both options, you need to add the command

npm run build;

after the lines below (please note that the two scripts are different and reside in different paths in our repository), and resume from the corresponding steps in each guide (i.e. step 5 in native build, and step 4 in build via docker image).

  1. For the option that builds the executable natively, add the command after line:

https://github.com/NASA-SW-VnV/fret/blob/2c5faa5f9bd52eec1cd14837737a4ce7fab8ca44/tools/Scripts/FRETExecutables/generate_executable_Linux.sh#L85

  1. For the option that builds the executable using the Docker image, add the command after the line:

https://github.com/NASA-SW-VnV/fret/blob/2c5faa5f9bd52eec1cd14837737a4ce7fab8ca44/tools/Scripts/docker/generate_executable_Linux.sh#L72

Additionally, for the Docker image fix, please keep in mind the following:

  1. Since you followed part of the steps successfully already, your generate_executable_Linux.sh file should now reside under fret and not fret/tools/Scripts/docker. After editing the script, delete your existing fret-desktop folder, and follow the Docker guide starting from step 4.
  2. You may encounter issues related to GLIBC if you use the default value for Ubuntu in the provided Dockerfile (FROM ubuntu:latest). If you do, please change this value to FROM ubuntu:focal and start again from step 4 of the Docker guide.

Please let us know if the above indeed fixes the issues on your end. If it does, feel free to close the issue.

Best Regards,

Andreas

andreaskatis avatar Oct 09 '24 17:10 andreaskatis

That did the trick, thanks!

sand7000 avatar Oct 09 '24 21:10 sand7000