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.

default java.io.tmp location is too long

See original GitHub issue

I have an issue with files created at temp directory having too long pathname. Please kindly see this SO question.

I managed to solve that by explicitly adding to my test target

"jvm_flags" = ["-Djava.io.tmpdir=/tmp"],

But that hurts the hermetical principle of testing. I suggest we offer much shorter yet unique tmp location for tests (somehting like /tmp/bazel-<unique-7-chars>)

WDYT?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:33 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
laszlocsomorcommented, Feb 16, 2018

FYI, I decided to roll back the --local_tmp_root flag, see: https://github.com/bazelbuild/bazel/issues/4621#issuecomment-366217321

For the record, there’s already a --test_tmpdir flag, which allows going down to a 42-character-long temp root, see https://github.com/bazelbuild/bazel/issues/4621#issuecomment-366217799

I’ll discuss with the team how to go forward.

0reactions
jmmvcommented, May 15, 2020

I generally agree with the sentiment that Bazel should be using TMPDIR-compliant paths. Unfortunately, Bazel as currently implemented, loves long paths. Addressing this specific issue here would add inconsistency, and it doesn’t seem trivial in this context. I also suspect several things would break given the current model in Bazel.

We have encountered this too in some tests and have fixed it by making any such affected test use /tmp directly, and then using mkdtemp or mkstemp to create directories or files safely within that. /tmp is open for writes from the sandbox, so this works.

Also, given that Unix domain socket names are restricted in length, any test that wants to create them must ensure that they fit within those limits. Relying on any environment variable or the cwd configured by Bazel to be “short enough” is bound to fail in some cases, so I’d say that we shouldn’t get into that business and that any tests relying on this specific limit must explicitly account for it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When does System.getProperty("java.io.tmpdir") return "c:\temp"
The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically "/tmp" ......
Read more >
Creating Temporary Directories in Java - Baeldung
The location is given by the java. io. tmpdir property, and every operating system has its own structure and cleanup routines.
Read more >
How to get the temporary file path in Java - Mkyong.com
For Windows, the default temporary folder is %USER%\AppData\Local\Temp · For Linux, the default temporary folder is /tmp ...
Read more >
Changing the system property java.io.tmpdir — oracle-tech
We are using System.getProperty("java.io.tmpdir") in our application running at Sun solaris box and it returns the value "var/tmp" .
Read more >
When "/tmp" and $TMPDIR directory are cleaned up in macOS?
Thanks for the explanation. ... defaults to 3, meaning that a file gets deleted if it hasn't been accessed in three days. Keep...
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