flathub / cc.arduino.IDE2

https://flathub.org/apps/details/cc.arduino.IDE2
6 stars 4 forks source link

App does not open on Arch, due to localhost resolution failure #38

Closed nyanpasu64 closed 1 year ago

nyanpasu64 commented 1 year ago

When I run flatpak run cc.arduino.IDE2, I see some terminal print messages, but no window appears:

nyanpasu64@ryzen ~> flatpak run cc.arduino.IDE2
Arduino IDE 2.0.4
Starting backend process. PID: 30
[30 zypak-helper] Using spawn strategy test 1 as set by environment
Gtk-Message: 00:30:31.768: Failed to load module "xapp-gtk3-module"
Gtk-Message: 00:30:31.768: Failed to load module "canberra-gtk-module"
[52:0324/003031.942854:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
Using browser-only version of superagent in non-browser environment
Configuration directory URI: 'file:///home/nyanpasu64/.theia'
Configuring to accept webviews on '^.+\.webview\..+$' hostname.
2023-03-24T07:30:32.431Z root INFO Backend Object.initialize: 2.8 ms [Finished 0.628 s after backend start]
2023-03-24T07:30:32.431Z root INFO Backend Object.configure: 2.2 ms [Finished 0.628 s after backend start]
2023-03-24T07:30:32.431Z root INFO Backend MessagingContribution.onStart: 1.0 ms [Finished 0.628 s after backend start]
2023-03-24T07:30:32.431Z root INFO Backend OSBackendApplicationContribution.configure: 0.3 ms [Finished 0.653 s after backend start]
2023-03-24T07:30:32.432Z root INFO Backend DefaultWorkspaceServer.onStart: 0.2 ms [Finished 0.653 s after backend start]
2023-03-24T07:30:32.432Z root INFO Backend PluginLocalizationBackendContribution.configure: 0.1 ms [Finished 0.654 s after backend start]
2023-03-24T07:30:32.433Z root INFO Backend PluginLocalizationBackendContribution.initialize: 25.5 ms [Finished 0.654 s after backend start]
2023-03-24T07:30:32.433Z root INFO Backend TaskBackendApplicationContribution.onStart: 0.2 ms [Finished 0.654 s after backend start]
2023-03-24T07:30:32.433Z root INFO Backend ElectronTokenBackendContribution.configure: 0.5 ms [Finished 0.654 s after backend start]
2023-03-24T07:30:32.434Z config INFO >>> Initializing CLI configuration...
2023-03-24T07:30:32.434Z root INFO Backend PluginDeployerContribution.initialize: 0.3 ms [Finished 0.654 s after backend start]
2023-03-24T07:30:32.434Z root INFO Backend ConfigServiceImpl.onStart: 0.5 ms [Finished 0.655 s after backend start]
2023-03-24T07:30:32.434Z config INFO Loading CLI configuration from /home/nyanpasu64/.arduinoIDE/arduino-cli.yaml...
2023-03-24T07:30:32.435Z root INFO Backend WebviewBackendSecurityWarnings.initialize: 0.3 ms [Finished 0.656 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend ArduinoDaemonImpl.onStart: 0.6 ms [Finished 0.656 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend NodeFileUploadService.configure: 1.1 ms [Finished 0.656 s after backend start]
2023-03-24T07:30:32.435Z daemon INFO Starting daemon from /app/arduino-ide/resources/app/node_modules/arduino-ide-extension/build/arduino-cli...
2023-03-24T07:30:32.435Z discovery-log INFO start
2023-03-24T07:30:32.435Z discovery-log INFO start new deferred
2023-03-24T07:30:32.435Z root INFO Backend HostedPluginLocalizationService.initialize: 0.3 ms [Finished 0.657 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend BoardDiscovery.onStart: 0.6 ms [Finished 0.657 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend FileDownloadEndpoint.configure: 0.5 ms [Finished 0.657 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend AuthenticationServiceImpl.onStart: 0.3 ms [Finished 0.658 s after backend start]
2023-03-24T07:30:32.435Z root INFO Backend PluginApiContribution.configure: 0.3 ms [Finished 0.658 s after backend start]
2023-03-24T07:30:32.436Z root INFO Backend HostedPluginReader.configure: 0.2 ms [Finished 0.658 s after backend start]
2023-03-24T07:30:32.436Z root INFO Backend HostedPluginReader.configure: 0.1 ms [Finished 0.658 s after backend start]
2023-03-24T07:30:32.436Z root INFO Backend PlotterBackendContribution.configure: 0.4 ms [Finished 0.659 s after backend start]
2023-03-24T07:30:32.437Z root ERROR Failed to start the backend application:
2023-03-24T07:30:32.437Z root ERROR Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
2023-03-24T07:30:32.437Z root ERROR Uncaught Exception: 
2023-03-24T07:30:32.437Z root ERROR Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
2023-03-24T07:30:32.445Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoIDE/plugins does not exist.
2023-03-24T07:30:32.445Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoIDE/extensions does not exist.
2023-03-24T07:30:32.445Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoProIDE/plugins does not exist.
[30 preload-host-spawn-strategy] Warning: kill override ignores groups

When I run paru -S arduino-ide-bin and install Arduino IDE v2 as an Arch AUR package rather than Flatpak, then run arduino-ide, the window appears normally.

Diffing the failed and successful startup, the biggest change is that with Flatpak Arduino, I see a message 2023-03-24T07:30:32.437Z root ERROR Failed to start the backend application: etc., while with native Arduino v2, I see:

2023-03-24T07:33:14.450Z root INFO Theia app listening on http://localhost:39157.
2023-03-24T07:33:14.451Z root INFO Finished starting backend application: 2.0 ms [Finished 0.461 s after backend start]
2023-03-24T07:33:14.455Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoIDE/plugins does not exist.
2023-03-24T07:33:14.455Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoIDE/extensions does not exist.
2023-03-24T07:33:14.455Z root WARN The local plugin referenced by local-dir:/home/nyanpasu64/.arduinoProIDE/plugins does not exist.
...

Full logs of IDE startup at https://gist.github.com/nyanpasu64/19025687f55daf485f8f78473eb208e6.

Debugging

https://forum.arduino.cc/t/arduino-ide-2-0-1-not-starting-error-failed-to-start-the-backend-application/1049953 indicates that "Failed to start the backend application" indicates that the IDE and CLI need to communicate over a localhost network port, but this is failing over Flatpak. Looking at the logs more closely, Error: getaddrinfo ENOTFOUND localhost seems to indicate that DNS resolution is failing in Flatpak?

My /etc/hosts does not contain a localhost entry. Perhaps this is https://wiki.archlinux.org/title/Network_configuration#localhost_is_resolved_over_the_network in action?

https://bugs.archlinux.org/task/56684 links to https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1415, which says that the Flatpak /etc/nsswitch.conf needs myhostname to properly resolve localhost without a /etc/hosts entry. Strangely, when I run flatpak run --command=sh cc.arduino.IDE2, cat /etc/nsswitch.conf already contains "myhostname", but getent hosts localhost (or ahosts) fails. So I'm not sure what's going wrong.

System info

Operating System: Arch Linux KDE Plasma Version: 5.27.3 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.8 Kernel Version: 6.2.6-zen1-1-zen (64-bit) Graphics Platform: X11 Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor Memory: 15.5 GiB of RAM Graphics Processor: AMD Radeon RX 570 Series Manufacturer: Gigabyte Technology Co., Ltd. Product Name: B550M DS3H

SuperNinja-4965 commented 1 year ago

It seems strange, Im using an arch system configured similarly to you but i do have localhost in /etc/hosts. Would you be able to try adding localhost to /etc/hosts. A few searches seem to agree with the idea about /etc/hosts: https://stackoverflow.com/questions/44009848/error-getaddrinfo-enotfound https://medium.com/swlh/node-js-error-message-getaddrinfo-enotfound-localhost-solution-9b2fa4f61a9c

nyanpasu64 commented 1 year ago

The app does start with 127.0.0.1 localhost added to /etc/hosts. But https://bugs.archlinux.org/task/56684 indicates that apps should be able to launch (using myhostname to resolve localhost) even without that entry present.

SuperNinja-4965 commented 1 year ago

The app does start with 127.0.0.1 localhost added to /etc/hosts. But https://bugs.archlinux.org/task/56684 indicates that apps should be able to launch (using myhostname to resolve localhost) even without that entry present.

you are correct. In theory it should not be necessary to make this change. I suspect this is an issue related to the way flatpak works and is implemented and not necessarily an issue with the package (the IDE package on flathub) its self. Like you said it could be https://wiki.archlinux.org/title/Network_configuration#localhost_is_resolved_over_the_network in action but thats not something i am able to fix here. Maybe reach out with a flatpak issue?