istio / istio.io

Source for the istio.io site
https://istio.io/
Apache License 2.0
761 stars 1.54k forks source link

make serve error "docker: poorly formatted environment contains whitespaces" #13363

Open samzong opened 1 year ago

samzong commented 1 year ago
make serve
docker: poorly formatted environment: variable '%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)' contains whitespaces.
See 'docker run --help'.
make: *** [serve] Error 125

my os info:

hugo env; docker --version; sw_vers; sysctl -n machdep.cpu.brand_string
hugo v0.113.0+extended darwin/arm64 BuildDate=unknown
GOOS="darwin"
GOARCH="arm64"
GOVERSION="go1.20.4"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"

Docker version 23.0.5, build bc4487a

ProductName:        macOS
ProductVersion:     13.3.1
ProductVersionExtra:    (a)
BuildVersion:       22E772610a

Apple M1 Max
ericvn commented 1 year ago

Does make clean yield the same error? If you change the https://github.com/istio/istio.io/blob/master/common/scripts/run.sh#L45 to add an echo does that help identify the failure? I suspect one of your environment variables is getting put into the env.file and that is causing the docker command to fail. You may be able to block it using https://github.com/istio/istio.io/blob/master/common/scripts/setup_env.sh#L98. Set a default value and it will be added to list in that file.

samzong commented 1 year ago

Does make clean yield the same error? If you change the https://github.com/istio/istio.io/blob/master/common/scripts/run.sh#L45 to add an echo does that help identify the failure? I suspect one of your environment variables is getting put into the env.file and that is causing the docker command to fail. You may be able to block it using https://github.com/istio/istio.io/blob/master/common/scripts/setup_env.sh#L98. Set a default value and it will be added to list in that file.

Yes, make clean is same mistake.

After tireless efforts, I finally found the root cause of the problem. It turns out that my recent switch to a new terminal tool, warp, introduced some special environmental variables, especially WARP_PS1, which caused the issue. There was also another problem with the ID #13364 related to it.

Eventually, I switched back to using iTerm2 and successfully ran make serve.

I submitted my issue feedback on Warp at https://github.com/warpdotdev/Warp/issues/3203. If anyone else experiences similar problems, I recommend switching to iTerm2 and continuing to monitor this issue's progress. Because this problem only occurs in certain scenarios, istio.io intervention may not be necessary.

Thank you again for your reply!

ericvn commented 1 year ago

Thanks of the feedback. You could set your own ENV_BLOCKLIST (start with the one in the script above, and add WARP_PS1).

ericvn commented 1 year ago

And maybe we can add an additional value to add to the default to simplify things.

samzong commented 1 year ago

Thanks of the feedback. You could set your own ENV_BLOCKLIST (start with the one in the script above, and add WARP_PS1).

Great! If unknown environment variables could cause some issues, would it be necessary to provide a designated env-file for Docker's environment variables? I'm not entirely clear on which environment variables are used in the current project. Do you have any better suggestions?

If possible, I can try to contribute to this capability.

ericvn commented 1 year ago

I pointed you to the setupenv.sh for the block list and https://github.com/istio/istio.io/blob/master/common/scripts/run.sh#L52 is where that is used. Basically we copy all the local environment variables except the blocked ones into the running container.

If there is a consistent environment variable that should be added to the list, that could be done. One can set their own version of the block list today (add the new list of variables to block to the end of the defined list.

export ENV_BLOCKLIST="^_\|^PATH=\|^GOPATH=\|^GOROOT=\|^SHELL=\|^EDITOR=\|^TMUX=\|^USER=\|^HOME=\|^PWD=\|^TERM=\|^RUBY_\|^GEM_\|^rvm_\|^SSH=\|^TMPDIR=\|^CC=\|^CXX=\|^MAKEFILE_LIST=\|^WARP_PS1=}"

That's sort of difficult. It might be better to create a new environment variable, ADDITIONAL_ENV_BLOCK_LIST and append that to the ENV_BLOCK_LIST variable. You would only need to set ADDTIONAL_ENV_BLOCK_LIST to "^WARP_PS1=". Code to do that would be in setupenv.sh.