Skip to content

Commit

Permalink
Added a couple warnings for situations that could cause the tmp-dir t…
Browse files Browse the repository at this point in the history
…o not be executable, to help troubleshooting if that causes issues.
  • Loading branch information
KevinCLydon committed Aug 13, 2024
1 parent 9f2fbb5 commit e608b05
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.broadinstitute.hellbender.utils.io.IOUtils;
import org.broadinstitute.hellbender.utils.runtime.RuntimeUtils;

import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.*;
Expand Down Expand Up @@ -167,6 +168,33 @@ public Object instanceMainPostParseArgs() {
final Path p = tmpDir.toPath();
try {
p.getFileSystem().provider().checkAccess(p, AccessMode.READ, AccessMode.WRITE);

// Warn if there's anything that prevents execution in the tmp dir because some tools need that
// Write an empty file to the tempdir
final Path tempFilePath = Files.createTempFile(p, "gatk_exec_test", null);
final File tempFile = tempFilePath.toFile();
tempFile.deleteOnExit();
// Add execute permissions
if(!tempFile.setExecutable(true, false)){
logger.warn(
"Cannot create executable files within the configured temporary directory. It is possible " +
"this user does not have the proper permissions to execute files within this directory. " +
"This can cause issues for some GATK tools. You can specify a different directory using " +
"--tmp-dir"
);
}
// Now check if the file can be executed
else if(!tempFile.canExecute()) {
logger.warn(
"User has permissions to create executable files within the configured temporary directory, " +
"but cannot execute those files. It is possible the directory has been mounted using the " +
"'noexec' flag. This can cause issues for some GATK tools. You can specify a different " +
"directory using --tmp-dir"
);
}



System.setProperty("java.io.tmpdir", IOUtils.getAbsolutePathWithoutFileProtocol(p));
} catch (final AccessDeniedException | NoSuchFileException e) {
// TODO: it may be that the program does not need a tmp dir
Expand Down

0 comments on commit e608b05

Please sign in to comment.