Skip to content

Clean up existing install/symlink before extracting .mpk#55

Merged
ThomasFarstrike merged 1 commit intoMicroPythonOS:mainfrom
bitcoin3us:fix/install-mpk-cleanup
Feb 21, 2026
Merged

Clean up existing install/symlink before extracting .mpk#55
ThomasFarstrike merged 1 commit intoMicroPythonOS:mainfrom
bitcoin3us:fix/install-mpk-cleanup

Conversation

@bitcoin3us
Copy link
Copy Markdown
Contributor

Summary

  • install_mpk() now removes the destination folder before extracting, preventing [Errno 17] EEXIST failures
  • Handles three cases: real directories (via shutil.rmtree), regular files, and symlinks including broken/dangling ones (via os.remove)
  • Fixes app reinstalls, updates, and recovery from partially failed installations
  • Also fixes the case where a dev symlink (e.g. apps/com.example.app -> ../../SomeProject/) blocks installation when the symlink target doesn't exist

Test plan

  • Install a new app from the App Store
  • Reinstall an app that is already installed
  • Install an app after a previously failed installation left a partial directory
  • Install an app when a dangling symlink exists at the destination path

🤖 Generated with Claude Code

install_mpk() would fail with EEXIST if the destination folder already
existed from a previous (possibly partial) install, or if a dangling
symlink occupied the path (e.g. a dev symlink whose target was removed).

Before extracting, now remove the destination if it is:
- A real directory (via shutil.rmtree)
- A regular file (via os.remove)
- A symlink, including broken ones (via os.remove as a fallback)

This enables clean reinstalls, updates, and recovery from failed
installs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ThomasFarstrike
Copy link
Copy Markdown
Contributor

Awesome, you are now officially a MicroPythonOS contributor!!!

@ThomasFarstrike ThomasFarstrike merged commit a147808 into MicroPythonOS:main Feb 21, 2026
@bitcoin3us
Copy link
Copy Markdown
Contributor Author

Thank you @ThomasFarstrike I can't believe it! It feels like winning the lottery 🥳

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