mbed-tools deploy fails while parsing .lib files
- Dominant language
- Python
- Stars
- 49
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
**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
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
2. Run `mbed-tools deploy`
**Expected behavior**
`mbed-tools deploy` should execute.
**Screenshots**
NA
**Desktop (please complete the following information):**
- OS: Windows
- Version: 10
**Mbed (please complete the following information):**
- Device: NUCLEO_F767ZI
- Mbed OS Version: #4587080dbb470294f623054db2a272f1570be327
- Mbed CLI 2 Version: 7.40.0
**Additional context**
NA
Contributor guide
Research direction
Start at the deploy entry point and the library handling shown in mbed_tools/cli/project_management.py and mbed_tools/project/_internal/libraries.py. Reproduce the issue with a .venv, a local mbed-os.lib, and mbed-tools deploy on Windows. Done means deploy completes without attempting to parse the virtualenv's pywintypes.lib file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100