Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin seems incompatible with configuration cache #406

Closed
lppedd opened this issue Sep 11, 2024 · 2 comments
Closed

Plugin seems incompatible with configuration cache #406

lppedd opened this issue Sep 11, 2024 · 2 comments

Comments

@lppedd
Copy link

lppedd commented Sep 11, 2024

When I try to enable Gradle's configuration cache, I received the following error.

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

2 problems were found storing the configuration cache.
- Plugin 'org.ajoberstar.grgit': external process started 'C:\Program Files\Git4Win\cmd\git.exe --version'
  See https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Plugin 'org.ajoberstar.grgit': external process started 'C:\Program Files\Git4Win\cmd\git.exe config --system --show-origin --list -z'
  See https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:external_processes
@xenoterracide
Copy link

this is because in order to be configuration cache compatible you can't fork a process, at least generally speaking (I understand there might be a way around that).

This is the solution which I copied shamelessly from spotless

  static void preventJGitFromCallingExecutables() {
    SystemReader reader = SystemReader.getInstance();
    SystemReader.setInstance(
      new SystemReader.Delegate(reader) {
        @Override
        public String getenv(String variable) {
          if ("PATH".equals(variable)) {
            return "";
          } else {
            return super.getenv(variable);
          }
        }
      }
    );
  }

I'm considering creating a shaded "fork" of jgit just for the purpose of applying this fix due to static usage. I say fork loosely because if you're doing more (which this plugin seems to), it wouldn't be a good idea to use it. jgit is unfortunately designed with mutable statics. I opened this bug for a discussion with the spotless guys if anyone is interested.

@ajoberstar ajoberstar pinned this issue Oct 5, 2024
@ajoberstar
Copy link
Owner

While we could use a workaround to prevent it looking for system config, that also has the downside of impacting builds that may rely on the system config being detected. It feels like trading existing compatibility for the performance boost of configuration cache, which for the legacy status of grgit isn't where I want to go.

Configuration cache has been a moving target over the years that sucks up too much maintenance time for me, so I plan to update the readme to say that it's explicitly not supported for grgit.

@ajoberstar ajoberstar closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants