kuiperzone / PupNet-Deploy

PupNet Deploy is a cross-platform deployment utility which packages your .NET project as a ready-to-ship installation file in a single step.
GNU Affero General Public License v3.0
193 stars 6 forks source link

RPM installation for PupNet HelloWorld has a missing requirement #10

Closed stuarthillary closed 1 year ago

stuarthillary commented 1 year ago

I successfully installed the RPM package for the PupNet HelloWorld application on RHEL 8.7.

The application aborts when running it

> helloworld
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode+Settings..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.TextInfo..cctor()
   at System.String.ToLowerInvariant()
   at System.Text.EncodingHelper.GetCharset()
   at System.Text.EncodingHelper.GetEncodingFromCharset()
   at System.ConsolePal.GetConsoleEncoding()
   at System.Console.get_OutputEncoding()
   at System.Console.CreateOutputWriter(System.IO.Stream)
   at System.Console.<get_Out>g__EnsureInitialized|26_0()
   at System.Console.get_Out()
   at System.Console.WriteLine(System.String)
   at HelloWorld.Program.Main(System.String[])

In this case, the helloworld application is not running in globalization invariant mode and thus requires the package libicu to be installed.

https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization https://github.com/dotnet/runtime/blob/main/docs/design/features/globalization-invariant-mode.md

From my limited understanding of RPM spec files, adding libicu to the Requires section of the spec file may fix this. Is there currently a way of controlling prerequisites for the RPM package creation using pupnet configuration?

Outside of this helloworld example, a .NET application may have more exotic package requirements e.g. if they make use of native Linux libraries.

kuiperzone commented 1 year ago

Thank you for the reply and suggestion. First off, I am curious:

If I understand you correctly, you say the RPM package of "Hello World" won't run because of a dependency, but the RPM package of PupNet-Deploy runs fine...

There is a workaround though, which is to use the RPM package for PupNet installation. https://github.com/kuiperzone/PupNet-Deploy/issues/8

Seems surprising?

But, yes, I can see the argument for including a "Requires" section in the configuration for RPM (and presumably for .deb files as well). I agree this is important especially if the app is using native linux libraries.

However, I remain a little disappointed with dotnet. Please correct me if my thinking here is misguided, but I had understood that a "self-contained" app deployed with all its runtime dependencies at least, I guess, for most non-exotic scenarios. It is disappointing therefore to see a "Hello World" app fail on a major distro such as RHEL.

UPDATE. A little more info below. Yes, I see the issue:

https://github.com/dotnet/runtime/issues/41350

It's a little tricky because we don't know exactly what the package name is. Eg., on Debian apt-get install libicu did not work but apt-get install libicu-dev did work as did apt-get install libicu63 in my case.

I think this whole area needs a little thinking about.

kuiperzone commented 1 year ago

Incidentally, if you build with --verbose, like: pupnet -k rpm --verbose

It will show the RPM .spec file:

Name: helloworld Version: 1.0.1 Release: 2 BuildArch: x86_64 Summary: A Hello World application License: GPL-3.0-or-later Vendor: Kuiper Zone Url: https://kuiper.zone

AutoReqProv: no BuildRequires: libappstream-glib

%check desktop-file-validate %{buildroot}/%{_datadir}/applications/.desktop appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/.metainfo.xml

%description A Hello World application

%files [FILES]

UPDATE: Actually, looking at the above, I included desktop-file-validate. On your system, this is almost certainly causing the issue: https://github.com/kuiperzone/PupNet-Deploy/issues/7

stuarthillary commented 1 year ago

If I understand you correctly, you say the RPM package of "Hello World" won't run because of a dependency, but the RPM package of PupNet-Deploy runs fine...

There is a workaround though, which is to use the RPM package for PupNet installation.

8

Seems surprising?

At a guess, this maybe because a dotnet tool would use invariant mode and so not run up against this particular problem?

However, I remain a little disappointed with dotnet. Please correct me if my thinking here is misguided, but I had understood that a "self-contained" app deployed with all its runtime dependencies at least, I guess, for most non-exotic scenarios. It is disappointing therefore to see a "Hello World" app fail on a major distro such as RHEL.

This was a conscious decision on behalf of the dotnet team, I think, look at the arguments in this section https://github.com/dotnet/runtime/blob/main/docs/design/features/globalization-invariant-mode.md#background

As an aside, other possible dependencies are listed here https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#rpm-dependencies

Whether these dependencies are required will depend on what functionality the app uses, and right now this places the onus on any .NET package authors and/or sysadmins.

kuiperzone commented 1 year ago

That is an incredibly helpful reply. Thank you. I'm looking in to it.

stuarthillary commented 1 year ago

I just found this additional advice for when installation of dependent packages is undesirable https://github.com/dotnet/core/blob/main/Documentation/self-contained-linux-apps.md

Looks to be quite an error prone procedure that requires a lot of testing.

kuiperzone commented 1 year ago

Hi @stuarthillary

Check out the latest version 1.3.0 which now supports dependencies for RPM and DEB. I've tested the HelloWorld RPM on a clean install of Alma 9, and it seems to work.

stuarthillary commented 1 year ago

I have tested the install of the RPM package on a clean RHEL 8.7, and it works, requiring the install of the dependency libicu.

I had a quick look at the latest changes to the Helloworld project and noticed that the RpmRequires section of the HelloWorld.pupnet.conf file lists

krb5-libs
libicu
openssl-libs

but that the dependencies listed here https://learn.microsoft.com/en-us/dotnet/core/install/linux-rhel#dependencies also has zlib as a dependency.

kuiperzone commented 1 year ago

Hi @stuarthillary

I've updated the HelloWorld project to add zlib.

Glad it works now. Thank you for you feedback and help on this.

Andy