z411 / trackma

Open multi-site list manager for Unix-like systems. (ex-wMAL)
https://z411.github.io/trackma
GNU General Public License v3.0
761 stars 82 forks source link

"Open containing folder" action uses a hard-coded path for `xdg-open` #726

Open magneticflux- opened 5 months ago

magneticflux- commented 5 months ago

The hard-coded path /usr/bin/xdg-open may not exist (such as when using NixOS), causing the "open containing folder" action to silently fail. This should simply use the appropriate $PATH entry (as with the macOS open added in https://github.com/z411/trackma/pull/447).

Logs from a failure:

Traceback (most recent call last):
  File "/nix/store/d37h5x02hg7d43nb8rdzwf76jyz05xbn-trackma-0.8.6/lib/python3.11/site-packages/trackma/ui/gtk/window.py", line 589, in _open_folder
    subprocess.Popen(["/usr/bin/xdg-open", os.path.dirname(filename)],
  File "/nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-python3-3.11.6/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/5k91mg4qjylxbfvrv748smfh51ppjq0g-python3-3.11.6/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/xdg-open'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/d37h5x02hg7d43nb8rdzwf76jyz05xbn-trackma-0.8.6/lib/python3.11/site-packages/trackma/ui/gtk/window.py", line 504, in _on_show_action
    self._open_folder(*data)
  File "/nix/store/d37h5x02hg7d43nb8rdzwf76jyz05xbn-trackma-0.8.6/lib/python3.11/site-packages/trackma/ui/gtk/window.py", line 594, in _open_folder
    raise utils.EngineError("Could not open folder.")
trackma.utils.EngineError: Could not open folder.
BigBoyBarney commented 5 months ago

Assuming xdg-open is in $PATH, simply replacing /usr/bin/xdg-open with xdg-open should solve this, right?

Or is NixOS using something else?

magneticflux- commented 5 months ago

Yes, it's available on the normal $PATH so just removing the absolute part should fix it.