Move cgroup check below help/completion/subcommands check

NixOS builds podman inside a sandbox and uses the `podman completion` subcommand.
While upgrading to Podman 6, we noticed that this command now started
failing in our build sandbox because of the cgroup check.
The cgroups are not relevant to completion generation.

Signed-off-by: Marie Ramlow <marie@marie.cologne>
This commit is contained in:
Marie Ramlow 2026-09-24 18:49:56 +02:00
parent 5866b09c1f
commit 7cef788844

View file

@ -266,8 +266,6 @@ func setupRemoteConnection(podmanConfig *entities.PodmanConfig) string {
func persistentPreRunE(cmd *cobra.Command, args []string) error {
logrus.Debugf("Called %s.PersistentPreRunE(%s)", cmd.Name(), strings.Join(os.Args, " "))
checkSupportedCgroups()
// Help, completion and commands with subcommands are special cases, no need for more setup
// Completion cmd is used to generate the shell scripts
if cmd.Name() == "help" || cmd.Name() == "completion" || cmd.HasSubCommands() {
@ -275,6 +273,8 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
return nil
}
checkSupportedCgroups()
podmanConfig := registry.PodmanConfig()
if !registry.IsRemote() {