default java.io.tmp location is too long
See original GitHub issueI 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:
- Created 6 years ago
- Comments:33 (23 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FYI, I decided to roll back the
--local_tmp_root
flag, see: https://github.com/bazelbuild/bazel/issues/4621#issuecomment-366217321For 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-366217799I’ll discuss with the team how to go forward.
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 usingmkdtemp
ormkstemp
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.