sajmons / CollimationCircles

Collimation Circles is application for precise telescope collimation
https://www.saimons-astronomy.com/software/collimation-circles
GNU Lesser General Public License v3.0
40 stars 2 forks source link

App doesn't run on ArchLinux #19

Closed MattBlack85 closed 5 months ago

MattBlack85 commented 7 months ago

hi @sajmons

I know the readme says it works with .NET7, I got .NET8 and I looked here and I gave it a try

I am able to compile it but when I run it it fails with the following:

Unhandled exception. System.Exception: Application requirements are not met. Try to set 'minLevel' to 'Trace' for 'logconsole' in NLog.config, for more information.
   at CollimationCircles.Program.Main(String[] args)
[1]    58494 IOT instruction (core dumped)  CollimationCircles

important notes:

my scripts were used to copy libHarfBuzzSharp.so and libSkiaSharp.so but I see those are not dynamically linked anymore and I am not copying them over under /usr/lib

❯ ldd build/CollimationCircles
    linux-vdso.so.1 (0x00007ffce357d000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x000072c7bcf84000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x000072c7bcf7f000)
    libz.so.1 => /usr/lib/libz.so.1 (0x000072c7bcf65000)
    libm.so.6 => /usr/lib/libm.so.6 (0x000072c7bce79000)
    librt.so.1 => /usr/lib/librt.so.1 (0x000072c7bce74000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x000072c7bce4d000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x000072c7bca00000)
    libc.so.6 => /usr/lib/libc.so.6 (0x000072c7bc81e000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000072c7bdaa0000)

the command I use to compile is still dotnet publish -c Release -f net8.0 -r $_flag -o build --self-contained true /p:PublishSingleFile=true /p:PublishReadyToRun=true

do you have any idea what I did wrong?

MattBlack85 commented 7 months ago

more context:

dotnet run -f net8.0 and Trace as loglevel gives me this back

❯ dotnet run -f net8.0
2024-02-06 16:26:09.4283|DEBUG|CollimationCircles.Services.AppService|Executing command 'dpkg-query -W -f=${Status}; ${Version}
 vlc'
2024-02-06 16:26:09.4522|ERROR|CollimationCircles.Services.AppService|Failed to execute command 'dpkg-query -W -f=${Status}; ${Version}
 vlc' 'An error occurred trying to start process 'dpkg-query' with working directory '/home/matt/data/repos/CollimationCircles/CollimationCircles'. No such file or directory'
2024-02-06 16:26:09.4534|DEBUG|CollimationCircles.Services.AppService|Executing command 'dpkg-query -W -f=${Status}; ${Version}
 libvlc-dev'
2024-02-06 16:26:09.4534|ERROR|CollimationCircles.Services.AppService|Failed to execute command 'dpkg-query -W -f=${Status}; ${Version}
 libvlc-dev' 'An error occurred trying to start process 'dpkg-query' with working directory '/home/matt/data/repos/CollimationCircles/CollimationCircles'. No such file or directory'
2024-02-06 16:26:09.4534|FATAL|CollimationCircles.Program|Application requirements are not met. Try to set 'minLevel' to 'Trace' for 'logconsole' in NLog.config, for more information.
Unhandled exception. System.Exception: Application requirements are not met. Try to set 'minLevel' to 'Trace' for 'logconsole' in NLog.config, for more information.
   at CollimationCircles.Program.Main(String[] args) in /home/matt/data/repos/CollimationCircles/CollimationCircles/Program.cs:line 26
MattBlack85 commented 7 months ago

which lead me to this https://github.com/sajmons/CollimationCircles/blob/8ec5a6c8d8e8d61ac03b5a5a89b969ea0718de5d/CollimationCircles/Services/AppService.cs#L201

I am keen to think the app uses dpkg to find if dependencies are installed? if so, how can we make it multi OS on Linux? Seems also lib names are hardcoded to be debian-like paths https://github.com/sajmons/CollimationCircles/blob/8ec5a6c8d8e8d61ac03b5a5a89b969ea0718de5d/CollimationCircles/Services/AppService.cs#L28

MattBlack85 commented 7 months ago

I thought today a patch may be easily help me out, and it does, but partially.

This is my patch

diff --color --unified --recursive --text CollimationCircles-version-3.1.0.orig/CollimationCircles/Services/AppService.cs CollimationCircles-version-3.1.0.new/CollimationCircles/Services/AppService.cs
--- CollimationCircles-version-3.1.0.orig/CollimationCircles/Services/AppService.cs 2024-02-05 07:46:47.000000000 +0100
+++ CollimationCircles-version-3.1.0.new/CollimationCircles/Services/AppService.cs  2024-02-07 12:44:53.871550179 +0100
@@ -305,11 +305,11 @@
     {
         bool result = true;

-        if (OperatingSystem.IsLinux())
-        {
-            result &= IsPackageInstalled(VLC).GetAwaiter().GetResult();
-            result &= IsPackageInstalled(LIBVLC_DEV).GetAwaiter().GetResult();
-        }
+        // if (OperatingSystem.IsLinux())
+        // {
+        //    result &= IsPackageInstalled(VLC).GetAwaiter().GetResult();
+        //    result &= IsPackageInstalled(LIBVLC_DEV).GetAwaiter().GetResult();
+        // }

         return result;
     }

dotnet run works and the app starts but when I compile it and move the bin under /usr/bin the .so under /usr/lib I can start it with the following error

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at CollimationCircles.ViewModels.AppLogViewModel..ctor(SettingsViewModel settingsViewModel)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at CommunityToolkit.Mvvm.DependencyInjection.Ioc.GetService[T]()
   at CollimationCircles.Controls.AppLogUserControl..ctor()
   at CollimationCircles.Views.MainView.!XamlIlPopulate(IServiceProvider, MainView)
   at CollimationCircles.Views.MainView..ctor()
   at CollimationCircles.App.OnFrameworkInitializationCompleted()
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at CollimationCircles.Program.Main(String[] args)
[1]    80567 IOT instruction (core dumped)  CollimationCircles

I believe this is the missing NLog.config file, it is in the build folder but where this should live on a Linux filesystem? /usr/share/.local?

sajmons commented 7 months ago

mattia, thank you for reporting this. Yes it's my bad! :( I have to little experiance vith Linux development, and I didn't take in to accoutn that there is manny different distros out there.

I'll take this code out. Thank you for pointing this out. 👍

MattBlack85 commented 7 months ago

thanks @sajmons really appreciate! Should you need a alpha-beta-stable Linux tester let me know, always wiling to help fellas :rocket:

sajmons commented 6 months ago

Thank you @MattBlack85! Thats offer I can not refuse! ;) Next release is around the corner, and if you really wanna help to squash some bugs, you can build camera-controls branch and test it. New addition to this version is UI to control UVC camera settings (not for Raspberry PI Cameras, at the moment, must add some code to support those too). If you own UVC camera and you have some spare time, I would be very thankfull if you can test this version.

MattBlack85 commented 6 months ago

@sajmons (this is for myself and future references, zvbi package is needed to make vlc opening v4l2 devices) I tried it and I can open my camera, what kind of tests you need from me? happy to help ya

sajmons commented 6 months ago

Curently there is issue with selecting correct UVC camera in CC. If you have notebook with builtin camera and external one, then it would be great if you can test if you can switch between both by entering v4l2:///dev/video0 and v4l2:///dev/video1 (or whatever) in address field. Then confirm if camera controls are working on both cameras while stream is running?

MattBlack85 commented 6 months ago

will get back to you later today with my findings

MattBlack85 commented 6 months ago

@sajmons I run my test on my laptop, it seems it works, but I cannot switch between the 2 cleanly, I must stop the camera and then I can start the second one. If I switch typing the address of the second camera, it does nothing. Hope this helps

sajmons commented 5 months ago

I'm closing this one, because requirements error is now resolved. App should run normaly after installing dependances: sudo apt-get install -y libvlc-dev

MattBlack85 commented 5 months ago

hi @sajmons do you plan a new release soon with those changes?

sajmons commented 5 months ago

@MattBlack85 yeah, there are two new beta releases available for testing. Latest is beta2 available here: https://github.com/sajmons/CollimationCircles/releases/tag/version-3.2.0-beta2

If you have time, you can test it. Camera controls is still work in progress. For now I would like to simplify camera streaming feature. I think it's much more user friendly with beta2 release. Tell me what you think.