ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).
https://gitter.im/ElectronNET/community
MIT License
7.32k stars 726 forks source link

ERR_ELECTRON_BUILDER_CANNOT_EXECUTE when trying to build a desktop app for Ubunto #770

Open sam-wheat opened 1 year ago

sam-wheat commented 1 year ago

I believe I am having a similar problem to what is found here and here. The error message I get is different so I will write a new issue. My goal is to produce a desktop app that will run on Linux. Per this issue I think what I am doing is supported.

Environment:

Windows 10 22H2 19045.2846

Visual Studio 2022 / latest

Unbutu running on WSL2 same physical machine as Windows

sam@UGLY:~/stuff/BlazorServerTest1$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy

dotnet, node and x11 are installed. xeyes/gedit runs correctly.

My app is Hello World, only mods from default Blazor template are to install Electron.Net Electron.Net versions 23.6.1 and 23.6.2-alpha-13 - both give same result.

Steps to reproduce On Windows open command line in .csproj folder:

dotnet electronize start

This works fine - Blazor runs in an Electron window.

In same command window:

C:\Projects\BlazorServerTest1\BlazorServerTest1>dotnet electronize build /target linux

Build Electron Application... Arguments: target = linux Build ASP.NET Core App for linux-x64... Executing dotnet publish in this directory: C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux Build ASP.NET Core App for linux-x64 under Release-Configuration... dotnet publish -r linux-x64 -c "Release" --output "C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux\bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --self-contained dotnet publish -r linux-x64 -c "Release" --output "C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux\bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --self-contained MSBuild version 17.5.1+f6fdcf537 for .NET Determining projects to restore... Restored C:\Projects\BlazorServerTest1\BlazorServerTest1\BlazorServerTest1.csproj (in 345 ms). BlazorServerTest1 -> C:\Projects\BlazorServerTest1\BlazorServerTest1\bin\Release\net6.0\linux-x64\BlazorServerTest1.dll BlazorServerTest1 -> C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux\bin\

Start npm install... npm install --production

added 49 packages, and audited 50 packages in 8s

found 0 vulnerabilities

ElectronHostHook handling started... Build Electron Desktop Application... Executing electron magic in this directory: C:\Projects\BlazorServerTest1\BlazorServerTest1\bin\desktop Create electron-builder configuration file... node build-helper.js electron.manifest.json

Package Electron App for Platform linux... npx electron-builder --config=./bin/electron-builder.json --linux --x64 -c.electronVersion=23.2.0 ΓÇó electron-builder version=23.6.0 os=10.0.19045 ΓÇó loaded configuration file=C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux\bin\electron-builder.json ΓÇó description is missed in the package.json appPackageFile=C:\Projects\BlazorServerTest1\BlazorServerTest1\obj\desktop\linux\package.json ΓÇó packaging platform=linux arch=x64 electron=23.2.0 appOutDir=C:\Projects\BlazorServerTest1\BlazorServerTest1\bin\Desktop\linux-unpacked ΓÇó scheduling remote build target=snap arch=x64 ΓÇó scheduling remote build target=appImage arch=x64 ΓÇó cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1i4dems": dial tcp 51.15.76.176:443: connectex: No connection could be made because the target machine actively refused it. attempt=0 waitTime=2 ΓÇó cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1i4dems": dial tcp 51.15.76.176:443: connectex: No connection could be made because the target machine actively refused it. attempt=1 waitTime=4 ΓÇó cannot get, wait error=Get "https://service.electron.build/find-build-agent?no-cache=1i4dems": dial tcp 51.15.76.176:443: connectex: No connection could be made because the target machine actively refused it. attempt=2 waitTime=6 Γ¿» Get "https://service.electron.build/find-build-agent?no-cache=1i4dems": dial tcp 51.15.76.176:443: connectex: No connection could be made because the target machine actively refused it. Γ¿» C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 failedTask=build stackTrace=Error: C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 at ChildProcess. (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\builder-util\src\util.ts:250:14) at Object.onceWrapper (node:events:510:26) at ChildProcess.emit (node:events:390:28) at ChildProcess.cp.emit (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (node:internal/child_process:1064:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) From previous event: at processImmediate (node:internal/timers:464:21) From previous event: at RemoteBuilder.build (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-lib\src\remoteBuilder\RemoteBuilder.ts:51:28) at RemoteTarget.finishBuild (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-lib\src\linuxPackager.ts:105:30) at async Promise.all (index 2) at AsyncTaskManager.awaitTasks (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\builder-util\src\asyncTaskManager.ts:65:25) at Packager.doBuild (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-lib\src\packager.ts:453:5) at Object.executeFinally (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\builder-util\src\promise.ts:12:14) at Packager._build (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-lib\src\packager.ts:376:31) at Packager.build (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\app-builder-lib\src\packager.ts:337:12) at Object.executeFinally (C:\Users\sam\AppData\Local\npm-cache_npx\009083ec26dc578f\node_modules\builder-util\src\promise.ts:12:14)

... done

Despite the above error msg binaries are still produced in bin\Desktop\linux-unpacked\resources\bin.

Copy files in folder above to home folder in WSL file subsystem. In my case this is \\wsl.localhost\Ubuntu\home\sam\stuff\BlazorServerTest1

In a terminal window on the Linux VM run the following:

sam@UGLY:~/stuff/BlazorServerTest1$ chmod 777 BlazorServerTest1

sam@UGLY:~/stuff/BlazorServerTest1$ ./BlazorServerTest1

Unhandled exception. SocketIOClient.ConnectionException: Cannot connect to server 'http://localhost/' ---> System.TimeoutException: The operation has timed out. --- End of inner exception stack trace --- at SocketIOClient.SocketIO.ConnectAsync() at ElectronNET.API.SocketIoFacade.Connect() at ElectronNET.API.BridgeConnector.get_Socket() at ElectronNET.API.WindowManager.CreateWindowAsync(BrowserWindowOptions options, String loadUrl) at ElectronNET.API.WindowManager.CreateWindowAsync(String loadUrl) at BlazorServerTest1.Program.ElectronBootstrap() in C:\Projects\BlazorServerTest1\BlazorServerTest1\Program.cs:line 80 at BlazorServerTest1.Program.<>c__DisplayClass0_0.<

b0>d.MoveNext() in C:\Projects\BlazorServerTest1\BlazorServerTest1\Program.cs:line 36 --- End of stack trace from previous location --- at System.Threading.Tasks.Task.<>c.b128_1(Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() at System.Threading.Thread.StartCallback() Aborted

Am I supposed to have a HTTP server runing on the Linux machine? Error message references files on my windows machine.... IDK why.

sam-wheat commented 1 year ago

In this issue it was requested to copy the project source to Ubunto and build. I did that - here is what I got:

sam@UGLY:~/stuff/BlazorServerTest1$ dotnet build

MSBuild version 17.3.2+561848881 for .NET Determining projects to restore... Restored /home/sam/stuff/BlazorServerTest1/BlazorServerTest1.csproj (in 458 ms). BlazorServerTest1 -> /home/sam/stuff/BlazorServerTest1/bin/Debug/net6.0/BlazorServerTest1.dll

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:03.73

sam@UGLY:~/stuff/BlazorServerTest1$ electronize start

Start Electron Desktop Application... Arguments:

dotnet publish -r linux-x64 -c "Debug" --output "/home/sam/stuff/BlazorServerTest1/obj/Host/bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --no-self-contained MSBuild version 17.3.2+561848881 for .NET Determining projects to restore... Restored /home/sam/stuff/BlazorServerTest1/BlazorServerTest1.csproj (in 473 ms). BlazorServerTest1 -> /home/sam/stuff/BlazorServerTest1/bin/Debug/net6.0/linux-x64/BlazorServerTest1.dll BlazorServerTest1 -> /home/sam/stuff/BlazorServerTest1/obj/Host/bin/

node_modules missing in: /home/sam/stuff/BlazorServerTest1/obj/Host/node_modules Start npm install... npm install /usr/bin/env: ‘bash\r’: No such file or directory

ElectronHostHook handling started... Invoke electron - in dir: /home/sam/stuff/BlazorServerTest1/obj/Host/node_modules/.bin ./electron "../../main.js" Unhandled exception. System.AggregateException: One or more errors occurred. (An error occurred trying to start process '/usr/bin/bash' with working directory '/home/sam/stuff/BlazorServerTest1/obj/Host/node_modules/.bin'. No such file or directory) ---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/usr/bin/bash' with working directory '/home/sam/stuff/BlazorServerTest1/obj/Host/node_modules/.bin'. No such file or directory at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at ElectronNET.CLI.ProcessHelper.CmdExecute(String command, String workingDirectoryPath, Boolean output, Boolean waitForExit) in C:_PrivateRepo\Electron.NET\ElectronNET.CLI\ProcessHelper.cs:line 40 at ElectronNET.CLI.Commands.StartElectronCommand.b17_0() in C:_PrivateRepo\Electron.NET\ElectronNET.CLI\Commands\StartElectronCommand.cs:line 178 at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b272_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at ElectronNET.CLI.Program.Main(String[] args) in C:_PrivateRepo\Electron.NET\ElectronNET.CLI\Program.cs:line 59 Aborted

sam-wheat commented 1 year ago

I fixed the npm error using the answer to this question.

Tried to run my app from source again at Ubunto terminal prompt:

sam@UGLY:~/stuff/BlazorServerTest1$ electronize start

Start Electron Desktop Application... Arguments:

dotnet publish -r linux-x64 -c "Debug" --output "/home/sam/stuff/BlazorServerTest1/obj/Host/bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --no-self-contained MSBuild version 17.3.2+561848881 for .NET Determining projects to restore... All projects are up-to-date for restore. BlazorServerTest1 -> /home/sam/stuff/BlazorServerTest1/bin/Debug/net6.0/linux-x64/BlazorServerTest1.dll BlazorServerTest1 -> /home/sam/stuff/BlazorServerTest1/obj/Host/bin/

node_modules missing in: /home/sam/stuff/BlazorServerTest1/obj/Host/node_modules Start npm install... npm install npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: 'image-size@1.0.2', npm WARN EBADENGINE required: { node: '>=14.0.0' }, npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' } npm WARN EBADENGINE }

up to date, audited 153 packages in 815ms

22 packages are looking for funding run npm fund for details

found 0 vulnerabilities

ElectronHostHook handling started... Invoke electron - in dir: /home/sam/stuff/BlazorServerTest1/obj/Host/node_modules/.bin ./electron "../../main.js" Electron Socket IO Port: 8000 Electron Socket started on port 8000 at ::1 ASP.NET Core Port: 8001 [1185:0424/180630.352942:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization [1235:0424/180630.428464:ERROR:gpu_memory_buffer_support_x11.cc(49)] dri3 extension not supported. stdout: Use Electron Port: 8000

ASP.NET Core Application connected... global.electronsocket vs057hfhE7d3iR9xAAAC 2023-04-25T01:06:30.707Z stdout: BridgeConnector connected!

stdout: Called Event BrowserWindowCreated - data 1

(node:1158) electron: Failed to load URL: http://localhost:8001/ with error: ERR_CONNECTION_REFUSED (Use electron --trace-warnings ... to show where the warning was created) stdout: info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:8001

stdout: ASP.NET Core host has fully started.

stdout: info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.

stdout: info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: /home/sam/stuff/BlazorServerTest1/obj/Host/bin/

Electron can't find my app but when I go to http://localhost:8001/ in my browser my app loads immediately without error.

    "Kestrel": {
        "EndPoints": {
          "Http": {
            "Url": "http://localhost:8001"
          }
        }
andrewschuler commented 1 year ago

I'm getting the exact same error on ubuntu with the demo api app. I just created an issue over there a few minutes ago before I saw this.

Frankly I've been working for several days to get ANY type of project to run or build on Linux with no success. If you figure this out PLEASE let me know. I've tried creating various types of new dotnet projects, then "electronizing" them. They all work on Windows but none work on Linux. All with different types of errors. I was hoping to use Linux as a build server to target Mac but this is a bit dis-heartening.

This error seems to be related to the graphics driver? My ubuntu instance is a VM running in Hyper-V

sam-wheat commented 1 year ago

@andrewschuler Andrew, you may want to try Photiono. I had problems with it initially, but they released a new build in the last few days. I just got a basic hello world app running on both Windows and Ubunto.

andrewschuler commented 1 year ago

@sam-wheat Thanks for that.

Some more information for you as well. All the errors I've been seeing have been with "electronize start". However I just tried to build the project with "electronize build /target linux" on Ubuntu. That builds successfully with the errors and the app runs as it should. From this experience it seems maybe 'electronize start' should only be used on Windows?

sam-wheat commented 1 year ago

@andrewschuler I'm just another user so I can't offer any guidance. You made it further than I did however. I was never able to get it to run on linux even if I built it on the linux machine.

andrewschuler commented 1 year ago

@andrewschuler I'm just another user so I can't offer any guidance. You made it further than I did however. I was never able to get it to run on linux even if I built it on the linux machine.

Trying building it with "electonize build /target linux". Then nagivate down to "bin/Desktop/linux-unpacked" and try to run the binary.

LapinskasL commented 4 months ago

@andrewschuler and @sam-wheat, did any of you find a solution? I'm getting the SocketIOClient.ConnectionException: Cannot connect to server 'http://localhost/' error, but on Windows.

sam-wheat commented 4 months ago

I ended up using a different platform and have not looked back. See my link to Photino above.


From: Lukas Lapinskas @.> Sent: Thursday, June 27, 2024 8:06 AM To: ElectronNET/Electron.NET @.> Cc: Sam Wheat @.>; Mention @.> Subject: Re: [ElectronNET/Electron.NET] ERR_ELECTRON_BUILDER_CANNOT_EXECUTE when trying to build a desktop app for Ubunto (Issue #770)

@andrewschulerhttps://github.com/andrewschuler and @sam-wheathttps://github.com/sam-wheat, did any of you find a solution? I'm getting the SocketIOClient.ConnectionException: Cannot connect to server 'http://localhost/' error, but on Windows.

— Reply to this email directly, view it on GitHubhttps://github.com/ElectronNET/Electron.NET/issues/770#issuecomment-2194966984, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEA2LWQMYFXRBKD3Z6DWVZTZJQS5XAVCNFSM6AAAAABKAEDCQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJUHE3DMOJYGQ. You are receiving this because you were mentioned.Message ID: @.***>

andrewschuler commented 4 months ago

Same as @sam-wheat , I punted on Linux support and jumped over to MAUI.