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

No such file or directory after upgrading to 4.0.0 #99

Closed
arhohuttunen opened this issue Mar 21, 2022 · 3 comments · Fixed by #100
Closed

No such file or directory after upgrading to 4.0.0 #99

arhohuttunen opened this issue Mar 21, 2022 · 3 comments · Fixed by #100

Comments

@arhohuttunen
Copy link

Summary

When running the gitPublishCommit command with version 4.0.0 or above the build fails with Exception caught during execution of add command. caused by No such file or directory. This was working before in the 3.0.1 version.

Build file

Example build file can be found in this project: https://github.com/arhohuttunen/awstestkit/blob/main/documentation/build.gradle.kts

There is currently no smaller project to demonstrate the issue but could be provided to reproduce the issue if needed.

Output

> Task :documentation:gitPublishCommit FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':documentation:gitPublishCommit'.
> Exception caught during execution of add command

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':documentation:gitPublishCommit'.
	stacktrace omitted
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
	at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:225)
	at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:1)
	at java_util_concurrent_Callable$call$0.call(Unknown Source)
	at org.ajoberstar.grgit.operation.AddOp.call(AddOp.groovy:38)
	at org.ajoberstar.grgit.operation.AddOp.call(AddOp.groovy)
	at java_util_concurrent_Callable$call.call(Unknown Source)
	at org.ajoberstar.grgit.internal.OpSyntax.samOperation(OpSyntax.groovy:26)
	at org.ajoberstar.grgit.internal.OpSyntax$samOperation.callStatic(Unknown Source)
	at org.ajoberstar.grgit.internal.OpSyntax$samOperation.callStatic(Unknown Source)
	at org.ajoberstar.grgit.Grgit.add(Grgit.groovy)
	at org.ajoberstar.gradle.git.publish.tasks.GitPublishCommit.commit(GitPublishCommit.java:47)
	stacktrace omitted
Caused by: java.io.IOException: No such file or directory
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.newTempFile(ObjectDirectoryInserter.java:242)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.toTemp(ObjectDirectoryInserter.java:168)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.insert(ObjectDirectoryInserter.java:111)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.insert(ObjectDirectoryInserter.java:87)
	at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:207)
	... 242 more

Looks similar to #65 and #35

MrBergin added a commit to DoGoodDev/blog that referenced this issue Mar 26, 2022
arhohuttunen added a commit to arhohuttunen/awstestkit that referenced this issue Apr 30, 2022
Use an earlier version as version 4.x is breaking the builds.

Ref: ajoberstar/gradle-git-publish#99
ciscoo added a commit to ciscoo/cxf-codegen-gradle that referenced this issue Aug 9, 2022
@ajoberstar
Copy link
Owner

ajoberstar commented Aug 14, 2022

Sorry for the delay. I appreciate the sample project and the links to those related issues. It seems like if the .gradle directory isn't present, it does a "Clean stale outputs" in between each of the publish tasks. So it deletes the repo after copy runs and before commit starts.

Will look through Gradle's docs/code/issues to see how we're supposed to handle this. gradle/gradle#9041 is an indication of where they're headed (not allowing two tasks to use the same directory). And I get it, in general, but there are use cases like this that aren't feasible to handle if they're going to fiddle with the directories all the time. Needs to be some way to say "I've got this, just leave my files alone".

ajoberstar added a commit that referenced this issue Aug 14, 2022
Gradle fairly aggressively tries to cleanup stale output files, with
the goal of reliable build caching to avoid the need to run "./gradlew
clean". However, this is problematic for tasks that have overlapping
output directories, as it makes it difficult for Gradle to track
what's stale.

In a prior version we added the @UntrackedTask annotation to all of
the publish tasks to avoid Gradle's state tracking. However, we use
the built-in Gradle Copy task for one part of our chain, which does
not have that annotation.

In cases where the .gradle directory was not present, we would see the
repository directory get deleted after the gitPublishCopy task ran,
because Gradle thought it was stale. In other cases it seemed to be
fine.

While I don't understand the details of how Gradle makes those
stale/fresh decisions, particularly in the absence of the .gradle
directory, it seems the key is using the runtime method equivalent of
the @UntrackedTask annotation (Task.doNotTrackState) to tell Gradle
not to do its state tracking for this one task.

We could still have issues in the future, but this seems to get us
over the immediate hurdle.

Fixes #99
@ajoberstar
Copy link
Owner

I think I've got a solution, will be releasing it as 4.1.1.

ajoberstar added a commit that referenced this issue Aug 14, 2022
Gradle fairly aggressively tries to cleanup stale output files, with
the goal of reliable build caching to avoid the need to run "./gradlew
clean". However, this is problematic for tasks that have overlapping
output directories, as it makes it difficult for Gradle to track
what's stale.

In a prior version we added the @UntrackedTask annotation to all of
the publish tasks to avoid Gradle's state tracking. However, we use
the built-in Gradle Copy task for one part of our chain, which does
not have that annotation.

In cases where the .gradle directory was not present, we would see the
repository directory get deleted after the gitPublishCopy task ran,
because Gradle thought it was stale. In other cases it seemed to be
fine.

While I don't understand the details of how Gradle makes those
stale/fresh decisions, particularly in the absence of the .gradle
directory, it seems the key is using the runtime method equivalent of
the @UntrackedTask annotation (Task.doNotTrackState) to tell Gradle
not to do its state tracking for this one task.

We could still have issues in the future, but this seems to get us
over the immediate hurdle.

Fixes #99
@arhohuttunen
Copy link
Author

Thanks for the fix!

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

Successfully merging a pull request may close this issue.

2 participants