Skip to content

Conversation

@andrewleech
Copy link

Summary

Fix mip_install failure on boards where /lib directory doesn't exist by default.

Problem

mpremote mip requires a path ending in /lib in sys.path to determine where to install packages, but does not create the directory itself. On boards without a pre-existing lib directory, stubber mcu-stubs fails with:

mpremote: Unable to find lib dir in sys.path

The existing code attempted to add /lib to sys.path, but had two issues:

  1. Wrong timing - it ran in run_createstubs() which is called after mip_install, so the path wasn't set when needed
  2. Wrong path format - used absolute /lib instead of os.getcwd() + '/lib' which mpremote expects (path must end with /lib but not start with /rom)

Solution

Add ensure_lib_directory() which creates the lib directory and adds it to sys.path before mip_install is called. Uses os.getcwd() + '/lib' to match mpremote's path matching logic. Removes the now-redundant sys.path code from run_createstubs().

Test plan

  • Run stubber mcu-stubs on a board without a pre-existing /lib directory
  • Verify mip_install succeeds and stubs are generated

mpremote mip requires a path ending in '/lib' in sys.path to determine
where to install packages, but it does not create the directory itself.
On boards where /lib doesn't exist by default, mip_install fails with:
"Unable to find lib dir in sys.path"

Add ensure_lib_directory() which creates the lib directory and adds
it to sys.path using os.getcwd() + '/lib'. This must be called before
install_scripts_to_board() which uses mip_install internally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants