Skip to content

Conversation

dpgeorge
Copy link
Member

If a ROMFS is mounted then "/rom/lib" is usually in sys.path before the writable filesystem's "lib" entry. The ROMFS directory cannot be installed to, so skip it if found.

Tested on PYBD_SF2.

Prior to this PR:

>>> import mip
>>> mip.install('unittest')
Installing unittest (latest) from https://micropython.org/pi/v2 to /rom/lib
Copying: /rom/lib/unittest/__init__.mpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mip/__init__.py", line 1, in install
  File "mip/__init__.py", line 1, in _install_package
  File "mip/__init__.py", line 1, in _install_json
  File "mip/__init__.py", line 1, in _download_file
  File "mip/__init__.py", line 1, in _ensure_path_exists
AttributeError: 'VfsRom' object has no attribute 'mkdir'

With this PR applied:

>>> import sys
>>> sys.path
['', '.frozen', '/rom', '/rom/lib', '/flash', '/flash/lib']
>>> import mip
>>> mip.install('unittest')
Installing unittest (latest) from https://micropython.org/pi/v2 to /flash/lib
Exists: /flash/lib/unittest/__init__.mpy
Done

If a ROMFS is mounted then "/rom/lib" is usually in `sys.path` before the
writable filesystem's "lib" entry.  The ROMFS directory cannot be installed
to, so skip it if found.

Signed-off-by: Damien George <[email protected]>
@dpgeorge dpgeorge merged commit 96e17b6 into micropython:master Mar 20, 2025
4 checks passed
@dpgeorge dpgeorge deleted the micropython-mip-skip-rom-lib branch March 20, 2025 03:37
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