Skip to content

Commit 118ce54

Browse files
committed
Improve the error message when running nested inside a non-Toolbx container
Fixes issue #1183 Signed-off-by: Nieves Montero <[email protected]>
1 parent b8138e0 commit 118ce54

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/cmd/root.go

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ func preRun(cmd *cobra.Command, args []string) error {
144144
}
145145
}
146146

147+
if utils.IsInsideContainer() && !utils.IsInsideToolboxContainer() {
148+
return createErrorNonToolboxContainer()
149+
}
150+
147151
toolboxPath := os.Getenv("TOOLBOX_PATH")
148152

149153
if toolboxPath == "" {

src/cmd/utils.go

+10
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ func createErrorInvalidRelease(hint string) error {
138138
return errors.New(errMsg)
139139
}
140140

141+
func createErrorNonToolboxContainer() error {
142+
var builder strings.Builder
143+
fmt.Fprintf(&builder, "this is not a Toolbox container.\n")
144+
fmt.Fprintf(&builder, "Toolbox is only meant to work with Toolbox containers.\n")
145+
fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
146+
147+
errMsg := builder.String()
148+
return errors.New(errMsg)
149+
}
150+
141151
func getUsageForCommonCommands() string {
142152
var builder strings.Builder
143153
fmt.Fprintf(&builder, "create Create a new toolbox container\n")

test/system/104-run.bats

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ load 'libs/bats-assert/load'
2020
load 'libs/helpers'
2121

2222
setup() {
23-
bats_require_minimum_version 1.7.0
2423
_setup_environment
2524
cleanup_containers
2625
}

0 commit comments

Comments
 (0)