Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call of export.sh in bash will end with an error, when $LANG is set (to non-english) (IDFGH-5432) #7173

Closed
3 tasks
happenpappen opened this issue Jun 20, 2021 · 7 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@happenpappen
Copy link

Environment

  • Development Kit: [ESP32-Wrover-Kit]
  • Kit version (for WroverKit/PicoKit/DevKitC): [v4]
  • Module or chip used: [ESP32]
  • IDF version (run git describe --tags to find it):
    v4.3
    v4.4-dev-1594-g1d7068e4b
  • Build System: [idf.py]
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it):
    xtensa-esp32-elf-gcc (crosstool-NG esp-2020r3) 8.4.0
  • Operating System: [Linux]
  • (Windows only) environment type: [MSYS2 mingw32|ESP Command Prompt|Plain Command Prompt|PowerShell].
  • Using an IDE?: [No]
  • Power Supply: [USB]

Problem Description

When sourcing the export.sh file with ". ./export.sh" the script will fail in bash, when $LANG is set to non-english. I tried this on Ubuntu 21.04 with $LANG set to "de_DE.UTF-8". The error stack is:

$ . ./export.sh
Detecting the Python interpreter
Checking "python" ...
Python 3.9.5
"python" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in /home/cs/.espressif/python_env/idf4.4_py3.9_env/bin/python
Checking if Python packages are up to date...
Python requirements from /tmp/esp-idf/requirements.txt are satisfied.
Added the following directories to PATH:
/tmp/esp-idf/components/esptool_py/esptool
/tmp/esp-idf/components/espcoredump
/tmp/esp-idf/components/partition_table
/tmp/esp-idf/components/app_update
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

idf.py build

Traceback (most recent call last):
File "/tmp/esp-idf/tools/idf.py", line 822, in
main()
File "/tmp/esp-idf/tools/idf.py", line 740, in main
cli(sys.argv[1:], prog_name=PROG, complete_var='_IDF.PY_COMPLETE')
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/core.py", line 1137, in call
return self.main(*args, **kwargs)
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/core.py", line 1057, in main
self._main_shell_completion(extra, prog_name, complete_var)
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/core.py", line 1132, in _main_shell_completion
rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/shell_completion.py", line 45, in shell_complete
echo(comp.source())
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/shell_completion.py", line 324, in source
self._check_version()
File "/home/cs/.espressif/python_env/idf4.4_py3.9_env/lib/python3.9/site-packages/click/shell_completion.py", line 319, in _check_version
raise RuntimeError(
RuntimeError: Couldn't detect Bash version, shell completion is not supported.

Expected Behavior

The script should work without above error, regardless the setting of $LANG, maybe it should store/restore the LANG setting while being executed.

Actual Behavior

See above traceback, there should be no error.

Steps to reproduce

  1. Start bash with $LANG set to de_DE.UTF-8 (i guess the error will happen with any language other than english)
  2. Change to esp-idf directory
  3. Source export.sh by entering ". ./export.sh"

Code to reproduce this issue

None needed.

Debug Logs

Other items if possible

  • sdkconfig file (attach the sdkconfig file from your project folder)
  • elf file in the build folder (note this may contain all the code details and symbols of your project.)
  • coredump (This provides stacks of tasks.)
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 20, 2021
@github-actions github-actions bot changed the title Call of export.sh in bash will end with an error, when $LANG is set (to non-english) Call of export.sh in bash will end with an error, when $LANG is set (to non-english) (IDFGH-5432) Jun 20, 2021
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jun 21, 2021
@ghost
Copy link

ghost commented Jun 22, 2021

@happenpappen Thank you for reporting the issue. RuntimeError is caused because of the way the click library is parsing the bash version. We contacted click developers and proposed a solution. Now we are waiting for the response. We will also publish a workaround soon.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress labels Jun 23, 2021
@ondrejdudasek
Copy link

For those in need of quick workaround, it's possible to get it working by modifiing two lines in shell_completion.py, on line 305:

output = subprocess.run(["bash", "-c", "echo $BASH_VERSION"], stdout=subprocess.PIPE)
match = re.search(r"(\d)\.(\d)\.\d", output.stdout.decode())

It requires echo command, but I haven't seen anything with bash without echo yet, so I think it should be universal.

@ghost
Copy link

ghost commented Jun 23, 2021

There's already a patch pull request to click pallets/click#1942.

@franz-ms-muc
Copy link
Contributor

it seems to be not fixed in the current ESP-IDF 4.3 ? right ?

@franz-ms-muc
Copy link
Contributor

but i can confirm, using the Patch from 23.06 works ...

@dobairoland
Copy link
Collaborator

@franz-ms-muc v4.3.1 released 18 days ago contains the fix.

@nopnop2002
Copy link

nopnop2002 commented Jun 23, 2022

This happens for python 3.9.

$ python --version
Python 3.9.2

Occurs regardless of the version of ESP-IDF.

I changed shell_completion.py:

    def _check_version(self) -> None:
        import subprocess

        output = subprocess.run(
            ["bash", "-c", "echo ${BASH_VERSION}"], stdout=subprocess.PIPE
        )
        #match = re.search(r"^(\d+)\.(\d+)\.\d+", output.stdout.decode())
        match = re.search(r"(\d)\.(\d)\.\d", output.stdout.decode())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants