Skip to content

Commit

Permalink
Make sure jupyter runtime dir actually exists before trying to write …
Browse files Browse the repository at this point in the history
…connection file
  • Loading branch information
fmagin committed Apr 8, 2024
1 parent 51e664a commit 9b7dff0
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -87,6 +88,16 @@ private static File writeConfigFile() {
}
String runtimeDir = getJupyterRuntime();
File kernelFile = new File(runtimeDir, String.format("kernel-%s.json", key));
// Make sure that the directory actually exists
// this is not guaranteed by only invoking `jupyter --runtime-dir`
// on new machines that never did anything with jupyter the directory won't exist
// and writing the file will fail
try {
Files.createDirectories(kernelFile.getParentFile().toPath());
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}

String connectionFile = formatConnectionFile(key, ports);

Expand Down

0 comments on commit 9b7dff0

Please sign in to comment.