Skip to content

touchy: don't crash on startup when nc_files dir is missing#4006

Open
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
grandixximo:touchy-filechooser-missing-dir
Open

touchy: don't crash on startup when nc_files dir is missing#4006
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
grandixximo:touchy-filechooser-missing-dir

Conversation

@grandixximo
Copy link
Copy Markdown
Contributor

Summary

lib/python/touchy/filechooser.py:reload() calls os.listdir(self.dir) with no error handling, where self.dir is hardcoded to $HOME/linuxcnc/nc_files. If that directory does not exist (fresh install, clean $HOME, sysadmin keeping NGC programs elsewhere) the FileNotFoundError propagates up and aborts touchy startup before any window appears.

Catch OSError, log the path that could not be read, continue with an empty file list. Touchy still starts; the user reaches programs through the normal file menu, and the quick-pick list populates the next time reload() is called once files exist.

Closes #4005.

Test plan

  • Local: HOME=/tmp/x linuxcnc -r configs/sim/touchy/touchy.ini now launches touchy with an empty quick-pick list and a stderr line touchy: filechooser cannot read /tmp/x/linuxcnc/nc_files: ...
  • Local: with the directory present, behaviour unchanged
  • Caught by the new ui-smoke tests in WIP: UI smoke tests for axis, touchy, gmoccapy, qtdragon #3999 (which currently work around the bug by mkdir -p $HOME/linuxcnc/nc_files); the workaround can be removed once this lands

Notes

  • Source path: src/emc/usr_intf/touchy/filechooser.py. The build copies this into lib/python/touchy/; that copy is gitignored.
  • Behaviour change is print-only on the failure path; no API changes.

filechooser.reload() called os.listdir(self.dir) with no error
handling, which crashes touchy at startup when the hardcoded
$HOME/linuxcnc/nc_files path does not exist (e.g. a fresh install,
a CI runner with a clean $HOME, or a sysadmin who keeps NGC
programs elsewhere). The traceback aborted the whole GUI before any
window appeared.

Catch OSError, log the path that could not be read, and continue
with an empty file list. Touchy still starts; the user can browse
to programs through the regular file menu and the quick-pick list
populates as soon as files appear.

Surfaced by ui-smoke testing (LinuxCNC#3999) on a clean GitHub Actions
$HOME. Closes LinuxCNC#4005.
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.

touchy: filechooser crashes if $HOME/linuxcnc/nc_files does not exist

2 participants