mu icon indicating copy to clipboard operation
mu copied to clipboard

Mu crashes on launch if device is connected and has little free space

Open inventhouse opened this issue 5 years ago • 4 comments

If a device with little free "disk" space is connected when Mu is started, it silently crashes without surfacing any error message in a way that a beginner might see.

In setup, Mu attempts to copy a number of assets to the device (#872), when that fails there isn't sufficient error handling to catch and surface the problem to the user, especially a novice.

As a workaround, I can "eject" my device, start Mu, then re-connect my board.

I'm running Mu 1.0.2 on macOS Mojave 10.14.5 (18F132) and have confirmed the problem with Adafruit Trinket M0; I don't know where the startup log is stored, but I diagnosed this issue by starting it directly on the command-line:

$ /Applications/mu-editor.app/Contents/MacOS/mu-editor Overriding built-in editor font due to Issue #552 Traceback (most recent call last): File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')() File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 144, in run editor.setup(setup_modes(editor, editor_window)) File "/Applications/mu-editor.app/Contents/Resources/app/mu/logic.py", line 598, in setup os.makedirs(fonts_path) File "/Users/travis/build/mu-editor/mu_portable_python_macos/python/lib/python3.6/os.py", line 220, in makedirs OSError: [Errno 28] No space left on device: '/Volumes/CIRCUITPY/fonts'

inventhouse avatar Jun 30 '19 12:06 inventhouse

Thanks for the repor @inventhouse.

If a device with little free "disk" space is connected when Mu is started, it silently crashes without surfacing any error message in a way that a beginner might see.

Does this mean the CircuitPython device crashes or Mu crashes?

carlosperate avatar Nov 08 '20 22:11 carlosperate

I just ran into this issue as well. It still exists with mu version 1.1.1.

  • I can confirm that it is mu that crashes and not CirciutPython.
  • The current version 1.1.1 takes you to the crash page via a browser. So the user is not TOTALLY in the dark. However, there is nothing to indicate WHY mu is trying to do what it is doing. So the user doesn't have much of a chance.
  • The code is erroneously trying to create copies of pygamezero resources on the device: images, fonts, sounds and music.
  • There is no reason whatsoever that mu should be creating these directories or copying these resources to the CircuitPython device.
  • The bad code is in logic.py Editor::setup().
  • I've attached a log file showing the crash. mu.log
  • My crash was on music_path instead of font_path (as reported above) because I DO have a font_path directory on the device.

My workaround was the same: disconnect the device, start up mu, then reconnect the device.

TonyLHansen avatar Apr 27 '22 13:04 TonyLHansen

The mu code appears to be returning the device's directory from base.py get_default_workspace(). When the device is not present, that function prints this message to the log:

2022-04-27 08:48:55,769 - mu.modes.base:68(get_default_workspace) WARNING: Workspace /Volumes/CIRCUITPY in the settings file is not a valid directory; using default /Users/wxyz/mu_code

Tracing back further, the file ~/Library/Application Support/mu/settings.json has this entry in it:

  "workspace": "/Volumes/CIRCUITPY",

It is unknown HOW that setting got there. But changing it to read the following prevents mu from crashing.

  "workspace": "/Users/wxyz/mu_code",

I don't know what else might be affected by making that change, but at least mu isn't crashing now. (And who knows what might cause it to be reset.)

TonyLHansen avatar Apr 27 '22 13:04 TonyLHansen

Bottom line, I consider there to be two bugs here:

  • get_default_workspace() should never return a directory path on the device. (Perhaps there could be a check in get_default_workspace() to return the default directory if it finds that the path has the device path at its beginning.)
  • Whatever code it was that SET "workspace" in settings.json to the device path ("/Volumes/CIRCUITPY") is probably incorrect.

TonyLHansen avatar Apr 27 '22 14:04 TonyLHansen