graal icon indicating copy to clipboard operation
graal copied to clipboard

Getting Error: Missing CAP cache value for: NativeCodeInfo:RISCV64LibCHelperDirectives:StructInfo:CPUFeatures

Open alina-yur opened this issue 1 year ago • 3 comments

Discussed in https://github.com/oracle/graal/discussions/9455

Originally posted by saradhipb August 6, 2024 I am very new to GraalVM tool, While run simple HelloWorld.java getting this error. Am using java 17.0.11 2024-04-16 LTS Java(TM) SE Runtime Environment Oracle GraalVM 17.0.11+7.1 (build 17.0.11+7-LTS-jvmci-23.0-b34) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.11+7.1 (build 17.0.11+7-LTS-jvmci-23.0-b34, mixed mode, sharing)

GraalVM Native Image: Generating 'helloworld' (executable)...

For detailed information and explanations on the build output, visit: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md

[1/8] Initializing... (0.0s @ 0.09GB) Error: Missing CAP cache value for: NativeCodeInfo:RISCV64LibCHelperDirectives:StructInfo:CPUFeatures Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception

                    0.2s (4.8% of total time) in 10 GCs | Peak RSS: 0.46GB | CPU load: 2.24

======================================================================================================================== Finished generating 'helloworld' in 4.4s.

How to get out from this error?

alina-yur avatar Aug 06 '24 12:08 alina-yur

Can you provide an unit test for this? This would help understanding the problem and having a definition of "done"

Similar bug in the past https://github.com/spectreconsole/spectre.console/issues/1400 My issue probably caused this change 😅

I guess there is no absolute right answer, and if it is it is harder to do than it may first look like

JKamsker avatar Feb 29 '24 22:02 JKamsker

I introduced the bug @JKamsker, unfortunately. I knew it was a breaking change, and flagged it as such, but I think the change in functionality is probably now best described as a regression. I'll add this to my stack to review/address.

https://github.com/spectreconsole/spectre.console/issues/1400#issuecomment-1866784986

And

FYI. I've submitted the PR above to revert this to existing behaviour @JKamsker

https://github.com/spectreconsole/spectre.console/issues/1400#issuecomment-1879765957

Background Apologies for creating this problem. The above issue description is exactly correct, we changed this behaviour between 0.47 and 0.48.

It had worked as per the current 0.48 earlier than 0.47, then I did some refactoring, changed it to the behaviour in 0.47, flagged it as a breaking change (thinking it was fine to make breaking changes, if warranted, as we are still < version 1.0), which was accepted by the maintainer team and merged.

Then we found a number of unhappy users of spectre.console (because we broke their apps), and so on further consideration, we reverted the change. Unfortunately, I doubt we'd be looking to revert it once again.

FrankRay78 avatar Mar 07 '24 08:03 FrankRay78

This appears fixed in 0.49.1 @BCoskun

I've created the following console application to test the behaviour:

using Spectre.Console;
using Spectre.Console.Cli;
using System.ComponentModel;

public class HelloCommandSettings : CommandSettings
{
    [CommandOption("-v|--version")]
    [DefaultValue("Hello world")]
    public string Message { get; set; }
}

public class HelloCommand : Command<HelloCommandSettings>
{
    public override int Execute(CommandContext context, HelloCommandSettings settings)
    {
        AnsiConsole.MarkupLine(settings.Message);
        return 0;
    }
}

public static class Program
{
    public static int Main(string[] args)
    {
        var app = new CommandApp();

        app.Configure(config =>
        {
            config.AddCommand<HelloCommand>("hello");
        });

        return app.Run(args);
    }

Behaviour under different spectre.console versions

0.47

image

0.48

image

0.49.1

image

FrankRay78 avatar Aug 12 '24 20:08 FrankRay78

There is still a bug, however, as when I add in the application version using the following configuration line:

            config.SetApplicationVersion("1.0");

The help text for the hello command erroneously includes the -v, --version associated at the application root:

image

At least the application behaviour is now functioning correctly.

FrankRay78 avatar Aug 12 '24 20:08 FrankRay78

Hey @JKamsker, if you have a minute, I'd love to hear your thoughts on the following test I'm authoring to address this issue, particularly the explanation given in the summary:

            /// <summary>
            /// When a command with a version flag in the settings is set as the application default command,
            /// then override the in-built Application Version flag with the command version flag instead.
            /// Rationale: This behaviour makes the most sense because the other flags for the default command
            /// will be shown in the help output and the user can set any of these when executing the application.
            /// </summary>
            [Theory]
            [InlineData("-?")]
            [InlineData("-h")]
            [InlineData("--help")]
            public void Help_Should_Include_Command_Version_Flag_For_Default_Command(string helpOption)
            {
                // Given
                var fixture = new CommandAppTester();
                fixture.SetDefaultCommand<Spectre.Console.Tests.Data.VersionCommand>();
                fixture.Configure(configurator =>
                {
                    configurator.SetApplicationVersion("1.0");
                });

                // When
                var result = fixture.Run(helpOption);

                // Then
                result.Output.ShouldContain("-v, --version    The command version");
                result.Output.ShouldNotContain("-v, --version    Prints version information");
            }

FrankRay78 avatar Aug 15 '24 22:08 FrankRay78