From 18a38b95b12bc54922ae057e882f934e83323f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Wed, 23 Sep 2020 17:57:10 +0200 Subject: [PATCH] cmd/run: Use home folder when $PWD is not in toolbox Since v0.0.91[0] Toolbox throws an error if $PWD is not available in a toolbox. While this fixes the problem with 'toolbox enter/run' silently failing to enter/exec in a container, it still requires an action to be made by the user. I believe it is better to handle such situations more gracefully by falling back to entering the user's home folder + printing a warning about doing so. [0] https://github.com/containers/toolbox/pull/370 --- src/cmd/run.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cmd/run.go b/src/cmd/run.go index ba1d189e3..96dbe9014 100644 --- a/src/cmd/run.go +++ b/src/cmd/run.go @@ -279,6 +279,15 @@ func runCommand(container string, } } + if pathPresent, _ := isPathPresent(container, workingDirectory); !pathPresent { + fmt.Fprintf(os.Stderr, "Error: path %s not found in container %s\n", + workingDirectory, container) + fmt.Fprintf(os.Stderr, "Using %s instead.\n", + currentUser.HomeDir) + + workingDirectory = currentUser.HomeDir + } + logrus.Debug("Checking if 'podman exec' supports disabling the detach keys") var detachKeys []string