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

Error: Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse #967

Closed
6 tasks done
pzygielo opened this issue Oct 13, 2021 · 5 comments · Fixed by #971
Closed
6 tasks done
Assignees
Labels

Comments

@pzygielo
Copy link
Contributor

pzygielo commented Oct 13, 2021

If you are submitting a bug, please include the following:

  • summary of problem
    Errors reported AFTER successful build.
  • gradle or maven version
    3.8.3
  • spotless version
    2.17.1
  • operating system and version
    Ubuntu/20.04.3
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>${spotless.version}</version>
                    <executions>
                        <execution>
                            <id>spotless-validation</id>
                            <phase>test</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <java>
                            <eclipse>
                                <file>file://${maven.multiModuleProjectDirectory}/build/eclipse-jdt-formatter.prefs</file>
                            </eclipse>
                        </java>
                        <cpp>
                            <includes>
                                <include>src/**/native/**/*.cpp</include>
                            </includes>
                            <eclipseCdt></eclipseCdt>
                        </cpp>
                    </configuration>
                </plugin>
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace
[INFO] 
[INFO] --- spotless-maven-plugin:2.17.1:check (spotless-validation) @ ... ---
[INFO] 
...
Error:  Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse12122245188339054218/.metadata/.plugins/org.eclipse.core.resources/0.snap'.
java.io.FileNotFoundException: /tmp/com_diffplug_spotless_extra_eclipse12122245188339054218/.metadata/.plugins/org.eclipse.core.resources/0.snap (No such file or directory)
    at java.io.FileOutputStream.open0 (Native Method)
    at java.io.FileOutputStream.open (FileOutputStream.java:298)
    at java.io.FileOutputStream.<init> (FileOutputStream.java:237)
    at java.io.FileOutputStream.<init> (FileOutputStream.java:158)
    at org.eclipse.core.internal.localstore.SafeChunkyOutputStream.<init> (SafeChunkyOutputStream.java:48)
    at org.eclipse.core.internal.localstore.SafeChunkyOutputStream.<init> (SafeChunkyOutputStream.java:44)
    at org.eclipse.core.internal.resources.SaveManager.snapTree (SaveManager.java:1474)
    at org.eclipse.core.internal.resources.SaveManager.save (SaveManager.java:1198)
    at org.eclipse.core.internal.resources.SaveManager.save (SaveManager.java:1143)
    at org.eclipse.core.internal.resources.DelayedSnapshotJob.run (DelayedSnapshotJob.java:55)
    at org.eclipse.core.internal.jobs.Worker.run (Worker.java:63)
@fvgh
Copy link
Member

fvgh commented Oct 14, 2021

I assure you that the Spotless version is not the issue here.

The temporary location is provided by spotless-eclipse-base.

When providing the formatters I did not manage to shutdown all Eclipse internal workers, without touching too many internal Eclipse classes. So the DelayedSnapshotJob and how temporary locations are handled is in the code since the very beginning.

Two things surprising me:

  • That the writing failed (.metadata directory is created by plugin). Do you have no write access to /tmp? Was disk full?
  • That the error had impact on your mvn execution (Eclipse Worker stops a failing job, but does not shutdown Eclipse). Can you provide the more information? Complete stack-trace, anything that gives me a clue how the error got propagated from the internal job to the spotless-plugin execution...

@pzygielo
Copy link
Contributor Author

* That the writing failed (`.metadata` directory is created by plugin). Do you have no write access to /tmp? Was disk full?

It's writeable for build process and is almost empty.

* That the error had impact on your `mvn` execution (Eclipse Worker stops a failing job, but does not shutdown Eclipse). Can you provide the more information? Complete stack-trace, anything that gives me a clue how the error got propagated from the internal job to the spotless-plugin execution...

I wasn't clear in my

Errors reported AFTER successful build.

It has no impact on mvn execution:

  • build completes with BUILD SUCCESS,
  • mvn exit code is 0.

Locally it happens only once in several runs. But when it does - it appears that there is leftover in /tmp, for example:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:39 min
[INFO] Finished at: 2021-10-14T16:38:59+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse8642527977178633303/.metadata/.plugins/org.eclipse.core.resources/0.snap'.
java.io.FileNotFoundException: /tmp/com_diffplug_spotless_extra_eclipse8642527977178633303/.metadata/.plugins/org.eclipse.core.resources/0.snap (No such file or directory)

then:

$ tree -a /tmp/com_diffplug_spotless_extra_eclipse8642527977178633303
/tmp/com_diffplug_spotless_extra_eclipse8642527977178633303
└── .metadata
    └── .plugins
        └── org.eclipse.jdt.core
            └── variablesAndContainers.dat

I assure you that the Spotless version is not the issue here.

Given exit code of 0 (which allows GitHub Actions/CI to pass without problem), it's possible that similar was logged previously indeed, and I didn't notice that before.

Unfortunately I wasn't able to prepare standalone reproducer yet.

@pzygielo pzygielo changed the title Error: Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse after 2.17.0->2.17.1 Error: Could not write workspace metadata '/tmp/com_diffplug_spotless_extra_eclipse Oct 14, 2021
@fvgh fvgh added bug and removed bug-unconfirmed labels Oct 14, 2021
@fvgh
Copy link
Member

fvgh commented Oct 14, 2021

Thanks @pzygielo . I know now where the problem is. DelayedSnapshotJob runs periodical and I have not synchronized it at shutdown. Never noticed when running gradle, since it uses a daemon concept.

Will provide a fix probably with the next release.

@nedtwigg
Copy link
Member

Fixed in plugin-gradle 5.17.1 and plugin-maven 2.17.3

@pzygielo
Copy link
Contributor Author

Thank you.

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.

3 participants