question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WindowsRegistry is not supported on this operating system.

See original GitHub issue

I’m hitting an exception, and I presume it is because of my companies anti-virus/malware software is blocking Gradle from reading the registry key \\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir. First thing to note is, I am working with my IT department to resolve this…

However, it doesn’t seem like Gradle should stop the flow here. It could consult with the PATH environment variable to locate vswhere.exe as a workaround or even skip this step entirely and look for the tool-chains in PATH. Any of these would be infinitely better then just throwing an exception and stopping the flow with no way to disable or bypass it.

Here is the exception:

Caused by: org.gradle.internal.nativeintegration.NativeIntegrationUnavailableException: WindowsRegistry is not supported on this operating system.
	at org.gradle.internal.nativeintegration.services.NativeServices$BrokenService.invoke(NativeServices.java:345)
	at com.sun.proxy.$Proxy112.getStringValue(Unknown Source)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.version.DefaultVswhereVersionLocator.getVswhereInstall(DefaultVswhereVersionLocator.java:48)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.version.CommandLineToolVersionLocator.locateInstalls(CommandLineToolVersionLocator.java:56)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.version.AbstractVisualStudioVersionLocator.getVisualStudioInstalls(AbstractVisualStudioVersionLocator.java:32)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.DefaultVisualStudioLocator.locateInstallsWith(DefaultVisualStudioLocator.java:108)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.DefaultVisualStudioLocator.initializeVisualStudioInstalls(DefaultVisualStudioLocator.java:97)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.DefaultVisualStudioLocator.locateComponent(DefaultVisualStudioLocator.java:86)
	at org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualCppToolChain.checkAvailable(VisualCppToolChain.java:175)

To locate the Visual Studios tools DefaultVswhereVersionLocator asks the registry for the Program Files or Program Files (x86) location and then appends Microsoft Visual Studio/Installer along with vswhere.exe. This action happens here:

    public File getVswhereInstall() {
        for (String programFilesKey : PROGRAM_FILES_KEYS) {
            File programFilesDir;
            try {
                programFilesDir = new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, REGISTRY_PATH_WINDOWS, programFilesKey));
            } catch (MissingRegistryEntryException e) {
                // We'll get this when we try to look up "ProgramFilesDir (x86)" on a 32-bit OS
                continue;
            }

            File candidate = new File(programFilesDir, VISUAL_STUDIO_INSTALLER + "/" + VSWHERE_EXE);
            if (candidate.exists() && candidate.isFile()) {
                return candidate;
            }
        }

        return os.findInPath(VSWHERE_EXE);
    }

The exception is thrown at:

                programFilesDir = new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, REGISTRY_PATH_WINDOWS, programFilesKey));

This windowsRegistry object is an instance of: net.rubygrapefruit.platform.WindowsRegistry

Perhaps one alternative would be to catch NativeIntegrationUnavailableException here.

The reason this is so problematic is it is one of the first things that happens in native tool-chain resolution. It is just initializing all of the tool-chains/install locations we haven’t even got to where we select the tools yet. From the aforementioned stack-trace you can see this method ( in DefaultVisualStudioLocator):

    private void initializeVisualStudioInstalls() {
        if (!initialised) {
            locateInstallsWith(commandLineLocator);   // <--- We are here when this throws
            locateInstallsWith(windowsRegistryLocator);
            if (foundInstalls.isEmpty()) {
                locateInstallsWith(systemPathLocator);
            }

            initialised = true;
        }
    }

We are still in commandLineLocator as it is trying to use vswhere.exe to locate the tools. Even if that fails and windowsRegistryLocator I think it would make sense to continue on to systemPathLocator, but we cannot even get to where it would locate tools using the PATH which would at least let me workaround this issue.

If you have any ideas I’d love to hear them because I’m not able to run C++ builds on Windows right now.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
melixcommented, Feb 3, 2022

Any workaround for this problem? It currently blocks testing Windows builds on GitHub actions… I should mention that in my case it seems to happen with TestKit: the Gradle build which starts the tests actually works properly.

0reactions
guaicommented, Mar 21, 2022

bump. In my case the error is different:

Caused by: org.gradle.internal.nativeintegration.NativeIntegrationUnavailableException: WindowsRegistry is not supported on this operating system.
        at org.gradle.internal.nativeintegration.services.NativeServices$BrokenService.invoke(NativeServices.java:445)
        at com.sun.proxy.$Proxy48.getSubkeys(Unknown Source)
        at org.gradle.jvm.toolchain.internal.WindowsInstallationSupplier.getVersions(WindowsInstallationSupplier.java:76)
        at org.gradle.jvm.toolchain.internal.WindowsInstallationSupplier.find(WindowsInstallationSupplier.java:67)
        at org.gradle.jvm.toolchain.internal.WindowsInstallationSupplier.findAdoptOpenJdk(WindowsInstallationSupplier.java:84)
        at org.gradle.jvm.toolchain.internal.WindowsInstallationSupplier.findInstallationsInRegistry(WindowsInstallationSupplier.java:52)
        at org.gradle.jvm.toolchain.internal.WindowsInstallationSupplier.findCandidates(WindowsInstallationSupplier.java:46)
        at org.gradle.jvm.toolchain.internal.AutoDetectingInstallationSupplier.get(AutoDetectingInstallationSupplier.java:41)
        at org.gradle.jvm.toolchain.internal.AutoDetectingInstallationSupplier.get(AutoDetectingInstallationSupplier.java:26)

It tries to read SOFTWARE\AdoptOpenJDK\JDK under HKEY_LOCAL_MACHINE. Last week everything was ok, dunno what happened.

gradle 7.4.1
Microsoft Windows 10 Enterprise 10.0.19044 Build 19044
JVM:          11.0.11 (Oracle Corporation 11.0.11+9-LTS-194)

PS: I have no Adopt installed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple operations fail if Windows 8 is improperly identified as ...
Open Registry editor (regedit.exe) · Locate and then select the following registry subkey: · From the right-side pane, double-click on ...
Read more >
You receive an error message when you try to access the ...
Click Start, click Run, type regedit, and then click OK. Expand the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ ...
Read more >
Windows 11 Product Name in registry - Microsoft Q&A
The registry keys such as "ProductName", ... doesn't stop installing because it thinks that Windows 11 is an unsupported operating system.
Read more >
Microsoft support policy for the use of registry cleaning utilities
Summary. This article describes the Microsoft support policy for customers who use registry cleaning utilities that rely on unsupported methods to extract ...
Read more >
GREG error - This operating system is not supported by this
If you know how to fix the above problem please let me know. I also have a problem with this." Windows detected your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found