Minikube: Default to bash shell when $SHELL is missing

Created on 23 Feb 2020  路  9Comments  路  Source: kubernetes/minikube

The current message is somewhat confused:

$ unset SHELL
$ minikube docker-env
The default lines below are for a sh/bash shell, you can specify the shell you're using, with the --shell flag.


馃挘  Error detecting shell: Error: Unknown shell

馃樋  minikube is exiting due to an error. If the above message is not useful, open an issue:
馃憠  https://github.com/kubernetes/minikube/issues/new/choose

causlibmachine-bug kinbug prioritbacklog

All 9 comments

It's equally confused upstream, always something.

$ unset SHELL
$ docker-machine env
The default lines below are for a sh/bash shell, you can specify the shell you're using, with the --shell flag.

Error: Unknown shell
$

I guess people normally don't unset their SHELL ?

First seen in #6643

Probably worth filing a bug in the https://github.com/actions/runner repository ?

Looks like it is written in .NET, and I'm not really sure where the VM / images are.

Similar failure with minikube podman-env (not surprising, same code)

I would be happy to review a PR that defaults to BASH_WITH_WARNNING if nothing else is found. (better not not giving anything)

however there should be a Warnning to the user in the Hint text in form a Comment
(because if we do glog.Warrnning it will ruin the eval command)

we could produce something like this for default

# Warning we couldn't detect the shell. providing Bash is default.

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://127.0.0.1:32778"
export DOCKER_CERT_PATH="/Users/medya/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube"

# To point your shell to minikube's docker-daemon, run:
# eval $(minikube -p minikube docker-env)

Cool let me give it a try, thanks @afbjorklund @medyagh

@medyagh : note that the initial bug is with libmachine, it prints an uncommented string on stdout...

https://github.com/docker/machine/blob/master/libmachine/shell/shell.go#L17_L26

    if shell == "" {
        fmt.Printf("The default lines below are for a sh/bash shell, you can specify the shell you're using, with the --shell flag.\n\n")
        return "", ErrUnknownShell
    }

So even when ErrUnknownShell is handled in minikube, that first line will still ruin the eval:

bash: unexpected EOF while looking for matching `''
bash: syntax error: unexpected end of file

Which basically means moving the os.Getenv("SHELL") to minikube.

And handle the unset ("") case, before it is even passed to libmachine ?

@medyagh : note that the initial bug is with libmachine, it prints an uncommented string on stdout...

https://github.com/docker/machine/blob/master/libmachine/shell/shell.go#L17_L26

  if shell == "" {
      fmt.Printf("The default lines below are for a sh/bash shell, you can specify the shell you're using, with the --shell flag.\n\n")
      return "", ErrUnknownShell
  }

So even when ErrUnknownShell is handled in minikube, that first line will still ruin the eval:

bash: unexpected EOF while looking for matching `''
bash: syntax error: unexpected end of file

Which basically means moving the os.Getenv("SHELL") to minikube.

And handle the unset ("") case, before it is even passed to libmachine ?

thanks for that finding ! yes I agree the problem is with the libmachine

Was this page helpful?
0 / 5 - 0 ratings