Skip to content

Commit

Permalink
cmd/run: Use home folder when $PWD is not in toolbox
Browse files Browse the repository at this point in the history
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] #370
  • Loading branch information
HarryMichal committed May 24, 2021
1 parent 66c49e0 commit 3db59ab
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3db59ab

Please sign in to comment.