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 Gradle 4.2 #35

Closed
sormuras opened this issue Sep 28, 2017 · 29 comments · Fixed by #39
Closed

No such file or directory after upgrading to Gradle 4.2 #35

sormuras opened this issue Sep 28, 2017 · 29 comments · Fixed by #39
Labels
Milestone

Comments

@sormuras
Copy link

sormuras commented Sep 28, 2017

I think this exception is related to gradle-git-publish when running on Gradle 4.2 -- or am I mistaken?

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
	at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:253)
	at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:85)
	at java_util_concurrent_Callable$call$0.call(Unknown Source)
	at org.ajoberstar.grgit.operation.AddOp.call(AddOp.groovy:53)
	at org.ajoberstar.grgit.operation.AddOp.call(AddOp.groovy)
	at java_util_concurrent_Callable$call.call(Unknown Source)
	at org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:33)
	at org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source)
	at org.ajoberstar.grgit.Grgit.add(Grgit.groovy)
	at org.ajoberstar.grgit.Grgit$add$7.call(Unknown Source)
	at org.ajoberstar.gradle.git.publish.GitPublishPlugin$_createCommitTask_closure5$_closure15.doCall(GitPublishPlugin.groovy:141)
	at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:700)
	at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:673)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
	... 94 more
Caused by: java.io.IOException: No such file or directory
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.newTempFile(ObjectDirectoryInserter.java:273)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.toTemp(ObjectDirectoryInserter.java:200)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectoryInserter.insert(ObjectDirectoryInserter.java:144)

See log after the upgrade to Gradle 4.2 with complete stacktrace at https://junit.ci.cloudbees.com/blue/organizations/jenkins/JUnit5/detail/JUnit5/2230/pipeline

Or this is the latest one with more debug information:
https://junit.ci.cloudbees.com/blue/rest/organizations/jenkins/pipelines/JUnit5/runs/2260/log/?start=0

@ajoberstar
Copy link
Owner

Just checked my compatibility suite and it passes against 4.2. Not to say those are exhaustive, so could be missing something.

That exception though seems more tied to general JGit behavior. So it could be something just in the general config/environment of the grgit/jgit.

Did you make any other changes to your Gradle build when moving to 4.2?

@sormuras
Copy link
Author

We did some changes like updating to latest versions of other plugins -- but after downgrading to Gradle 4.1 the gradle-git-publish, grgit/jgit issue disappeared.

@ajoberstar
Copy link
Owner

Interesting. I spent a few minutes trying to recreate this with the JUnit5 repo, but was having trouble (and the build is quite time consuming). If you can reproduce this in a smaller sample, that would be helpful.

@sormuras
Copy link
Author

sormuras commented Oct 6, 2017

I was not able to create a smaller example that shows the issue. ):

We still do observe a working Gradle 4.1 + Jenkins setup. When we re-upgrade to Gradle 4.2.x (or later) and the issue raises again, I'll come back to you.

@ajoberstar
Copy link
Owner

Sounds good.

@danielvanmil
Copy link

Same issue here. Any progress on this? Thanks.

@ajoberstar
Copy link
Owner

No progress yet. If you have something reproducible that I can test with that would help.

@sormuras
Copy link
Author

With JDK 9.0.1 released, we need to upgrade to Gradle 4.3 (4.3-rc-2 at the moment) ... so chances are high that we'll run into this issue soon. Or there was a bug fix from 4.2 to 4.3... ;)

@sormuras
Copy link
Author

The issue is still "alive".

See https://junit.ci.cloudbees.com/blue/organizations/jenkins/JUnit5/detail/master/23/pipeline/ for a ./gradlew --no-daemon --stacktrace --debug gitPublishPush run.

@sormuras
Copy link
Author

sormuras commented Oct 18, 2017

@ajoberstar
Copy link
Owner

The stack trace indicates we're failing creating a temp file inside of the object directory. Not sure why that would be missing at that point in the build. I'll try to run your project again tomorrow and see if I can reproduce it locally.

@sormuras
Copy link
Author

Thanks in advance. I'll keep the --debug and --stacktrace options enabled -- if a publish action fails, the log should point us to the underlying issue. Hopefully.

Btw. I found following warning in the full log of run 23:

05:48:01.808 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':gitPublishPush'
05:48:01.810 [WARN] [org.gradle.internal.featurelifecycle.LoggingDeprecatedFeatureHandler] The Task.dependsOnTaskDidWork() method has been deprecated and is scheduled to be removed in Gradle 5.0. Instead, check the value of "didWork()" for each task, or declare the task inputs and outputs and let Gradle decide what needs to be run.
	at org.gradle.api.internal.AbstractTask.dependsOnTaskDidWork(AbstractTask.java:580)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
	at org.ajoberstar.gradle.git.publish.GitPublishPlugin$_createPushTask_closure6$_closure16.doCall(GitPublishPlugin.groovy:160)

@sormuras
Copy link
Author

Run 24 now failed with --debug and --stacktrace enabled:
https://junit.ci.cloudbees.com/blue/organizations/jenkins/JUnit5/detail/master/24/pipeline/

@ajoberstar
Copy link
Owner

So far I haven't gotten as far as your build does. On my desktop, it keeps crashing during the startup of gitPublishCopy trying to "delete stale outputs", which for some reason includes it trying to delete the repository. It specifically fails trying to delete one particular pack file.

Not entirely sure it's related, but if Gradle's trying to delete the repository (and succeeds), that could result in a lack of an object directory when it gets to the add in gitPublishCommit.

Will try backing this down to 4.1 and see if it still does the same for me.

@ajoberstar
Copy link
Owner

While that 4.1 runs, looking at Gradle source and it seems that stale outputs cleanup was introduced in 4.2. This might be a matter of some missing output declarations on my part in the tasks in this plugin.

@ajoberstar
Copy link
Owner

And yes, 4.1 worked locally for me. Not sure why your build got farther than mine (maybe some Windows vs Linux differences), but seems like they both might be related to the stale outputs cleanup.

ajoberstar added a commit that referenced this issue Oct 20, 2017
As of Gradle 4.2, when execution of a task begins, any "stale" outputs
will be deleted. All files under build and any declared outputs are
considered managed by Gradle. If other files happen to be in there,
Gradle will delete them.

The reset task did not declare any outputs, but created the
build/gitPublish directory and cloned the repo in there. When the copy
task rolls around, it sees some that cloned repo as stale files in its
output directory, since the copy task didn't put them there. Since they
are also under build, Gradle considers itself the owner and thinks it's
safe to delete them.

By declaring the repodir as an output, the intent is to prevent Gradle
from considering those stale outputs. We still need to be careful not to
make Gradle do up-to-date logic on the reset task, since that isn't
really possible to declare with normal Gradle input options.

This is intended to address #35.

[1] https://docs.gradle.org/4.2/release-notes.html#safer-handling-of-stale-output-files
ajoberstar added a commit that referenced this issue Oct 20, 2017
As of Gradle 4.2, when execution of a task begins, any "stale" outputs
will be deleted. All files under build and any declared outputs are
considered managed by Gradle. If other files happen to be in there,
Gradle will delete them.

The reset task did not declare any outputs, but created the
build/gitPublish directory and cloned the repo in there. When the copy
task rolls around, it sees some that cloned repo as stale files in its
output directory, since the copy task didn't put them there. Since they
are also under build, Gradle considers itself the owner and thinks it's
safe to delete them.

By declaring the repodir as an output, the intent is to prevent Gradle
from considering those stale outputs. We still need to be careful not to
make Gradle do up-to-date logic on the reset task, since that isn't
really possible to declare with normal Gradle input options.

This is intended to address #35.

[1] https://docs.gradle.org/4.2/release-notes.html#safer-handling-of-stale-output-files
@ajoberstar
Copy link
Owner

Pushing out a 0.3.2-rc.1, including what seems to be a fix for this. Haven't figured out if/how I can make a test for this in this repo, but it seems to resolve the stale outputs issue in the junit5 project.

@sormuras
Copy link
Author

I'll try it right away...

sormuras added a commit to junit-team/junit5 that referenced this issue Oct 20, 2017
@sormuras
Copy link
Author

sormuras commented Oct 20, 2017

Run 32 is green on the first attempt:
https://junit.ci.cloudbees.com/blue/organizations/jenkins/JUnit5/detail/master/32/pipeline

A comment from @wolfs or sombody else from Gradle would be welcome regarding this issue.

@sormuras
Copy link
Author

Run 33 does not longer use --debug anymore. And it is green!

Thanks Andrew for fixing this!

@wolfs
Copy link

wolfs commented Oct 20, 2017

@sormuras I commented on #39. The problem you are experiencing is due to better stale output file handling as already correctly analyzed by @ajoberstar. There are problems when tasks which declare outputs write to the same files/directories as tasks which do not. So either all the tasks writing to one directory should declare their input and outputs correctly or none of the tasks should declare any inputs or outputs.

@sormuras
Copy link
Author

Thanks for chiming in @wolfs -- much appreciated.

@ajoberstar
Copy link
Owner

Thanks for testing @sormuras and thanks for the feedback @wolfs!

ajoberstar added a commit that referenced this issue Oct 21, 2017
As of Gradle 4.2 [1], when execution of a task begins, any "stale" outputs
will be deleted. All files under build and any declared outputs are
considered managed by Gradle. If other files happen to be in there,
Gradle will delete them.

The reset task did not declare any outputs, but created the
build/gitPublish directory and cloned the repo in there. When the copy
task rolls around, which is a built in task with declared
inputs/outputs, it sees some that cloned repo as stale files in its
output directory, since the copy task didn't put them there. Since they
are also under build, Gradle considers itself the owner and thinks it's
safe to delete them.

Since the inputs/outputs of the tasks in this plugin both overlap and
sometimes aren't clear files in / files out situations, it is easier for
now to drop using them altogether.

This commit drops the use of the Copy task, in favor of a ad-hoc task
that uses project.copy. This was the only task that had any
inputs/outputs declared before, so this issue should no longer be able
to present.

This fixes #35.

[1] https://docs.gradle.org/4.2/release-notes.html#safer-handling-of-stale-output-files
@ajoberstar
Copy link
Owner

@sormuras 0.3.2-rc.2 is out using a different approach mentioned by @wolfs. If you have a chance let me know if this one works for you too. It worked in my local copy of junit5.

ajoberstar added a commit that referenced this issue Oct 21, 2017
As of Gradle 4.2 [1], when execution of a task begins, any "stale" outputs
will be deleted. All files under build and any declared outputs are
considered managed by Gradle. If other files happen to be in there,
Gradle will delete them.

The reset task did not declare any outputs, but created the
build/gitPublish directory and cloned the repo in there. When the copy
task rolls around, which is a built in task with declared
inputs/outputs, it sees some that cloned repo as stale files in its
output directory, since the copy task didn't put them there. Since they
are also under build, Gradle considers itself the owner and thinks it's
safe to delete them.

Since the inputs/outputs of the tasks in this plugin both overlap and
sometimes aren't clear files in / files out situations, it is easier for
now to drop using them altogether.

This commit drops the use of the Copy task, in favor of a ad-hoc task
that uses project.copy. This was the only task that had any
inputs/outputs declared before, so this issue should no longer be able
to present.

This fixes #35.

[1] https://docs.gradle.org/4.2/release-notes.html#safer-handling-of-stale-output-files
@sormuras
Copy link
Author

@ajoberstar
Copy link
Owner

Great! Thanks!

@chali
Copy link

chali commented Jan 26, 2019

Hi, see this issue back. I have the plugin in version 2.0.0 and Gradle 5.1.1. I see this when :gitPublishCopy execution started.
17:36:33.331 [INFO] [org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter] Deleting stale output file: /Users/mchalupa/projects/others/genie/build/gitPublish

It happens only when I remove .gradle from the project. All following calls are working fine. However, our CI build always starts with fresh clone so it always fails.

@ajoberstar
Copy link
Owner

@chali Just from the description, I could see this as potentially expected (though undesired) behavior. With just the .gradle/ deleted but build/ still there, the cache and output dirs and out of sync. Deleting both .gradle/ and build/ (or neither) is probably what the Gradle folks would recommend.

If that doesn't work, can you open a new issue with some details of a working vs non-working config? Might be able to hunt down where the difference is.

@chali
Copy link

chali commented Jan 28, 2019

@ajoberstar thank you for quick follow up. The problem happens during a fresh clone and I verified that it happens even when I include clean task. I think that rules out the .gradle/ and build/ inconsistency as a cause. I will try to prepare a smaller example and open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants