Ensure lib directory exists before mip_install #703
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix mip_install failure on boards where
/libdirectory doesn't exist by default.Problem
mpremote mip requires a path ending in
/libinsys.pathto determine where to install packages, but does not create the directory itself. On boards without a pre-existing lib directory,stubber mcu-stubsfails with:The existing code attempted to add
/libtosys.path, but had two issues:run_createstubs()which is called aftermip_install, so the path wasn't set when needed/libinstead ofos.getcwd() + '/lib'which mpremote expects (path must end with/libbut not start with/rom)Solution
Add
ensure_lib_directory()which creates the lib directory and adds it tosys.pathbeforemip_installis called. Usesos.getcwd() + '/lib'to match mpremote's path matching logic. Removes the now-redundant sys.path code fromrun_createstubs().Test plan
stubber mcu-stubson a board without a pre-existing/libdirectory