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 Sep 23, 2020
1 parent ff4e490 commit ef8299d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ 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 home folder %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 ef8299d

Please sign in to comment.