ARMmbed / mbed-tools

⚠️ Beta Status: New command line tooling for Mbed OS
Apache License 2.0
45 stars 30 forks source link

mbed-tools deploy fails while parsing .lib files #318

Open nat45928 opened 3 years ago

nat45928 commented 3 years ago

Describe the bug It appears while searching for .lib files mbed-tools is able to traverse into tooling folders, namely a co-located virtualenv and attempts to parse invalid .lib files.

The exact traceback is:

> mbed-tools deploy
Checking out all libraries to revisions specified in .lib files. Resolving any unresolved libraries.
Traceback (most recent call last):
  File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\myfiles\firmware\.venv\Scripts\mbed-tools.exe\__main__.py", line 7, in <module>
  File "d:\myfiles\firmware\.venv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "d:\myfiles\firmware\.venv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "d:\myfiles\firmware\.venv\lib\site-packages\mbed_tools\cli\main.py", line 38, in invoke
    super().invoke(context)
  File "d:\myfiles\firmware\.venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "d:\myfiles\firmware\.venv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "d:\myfiles\firmware\.venv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "d:\myfiles\firmware\.venv\lib\site-packages\mbed_tools\cli\project_management.py", line 83, in deploy
    deploy_project(root_path, force)
  File "d:\myfiles\firmware\.venv\lib\site-packages\mbed_tools\project\project.py", line 70, in deploy_project
    libs.fetch()
  File "d:\myfiles\firmware\.venv\lib\site-packages\mbed_tools\project\_internal\libraries.py", line 65, in fetch
    git_ref = lib.get_git_reference()
  File "d:\myfiles\firmware\.venv\lib\site-packages\mbed_tools\project\_internal\libraries.py", line 46, in get_git_reference
    raw_ref = raw_bytes.decode('utf-8').strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 71: invalid start byte

In my case it appears to be parsing the file .venv\Lib\site-packages\win32\libs\pywintypes.lib.

To Reproduce

  1. Create a virtual env in .venv
  2. Install mbed-tools with a local mbed-os.lib file
  3. Run mbed-tools deploy

Expected behavior mbed-tools deploy should execute.

Screenshots NA

Desktop (please complete the following information):

Mbed (please complete the following information):

Additional context NA

BioBox commented 2 years ago

Why are you using a python virtual environment in your mbed project folder when all the code is in C++? Just store your .venv folder somewhere else or better yet, don't use a virtual environment at all. Problem solved.