Skip to content

Commit c9876f4

Browse files
committed
Overwrite parent commands PreRun code for compose version
.. to avoid trying (and failing) to load a compose file if the COMPOSE_FILE env var is set such as `COMPOSE_FILE=foo compose version` Signed-off-by: Laura Brehm <[email protected]>
1 parent 70ccc98 commit c9876f4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmd/compose/version.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func versionCommand() *cobra.Command {
4242
runVersion(opts)
4343
return nil
4444
},
45+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
46+
// overwrite parent PersistentPreRunE to avoid trying to load
47+
// compose file on version command if COMPOSE_FILE is set
48+
return nil
49+
},
4550
}
4651
// define flags for backward compatibility with com.docker.cli
4752
flags := cmd.Flags()

0 commit comments

Comments
 (0)