trash-rs: Tests on MacOS fail because AppleScript is not available on Github Actions

The current MacOS implementation uses an AppleScript to put files into the Trash. But this hangs on Github Actions. See also https://github.com/Homebrew/homebrew-cask/issues/19076

A solution for this could be to use the Cocoa API. For example recycleURLs is a good candidate.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Thanks for reporting! I’d hope that this fixes itself once the runner-image receives updates, but if not it should be possible to use the alternative implementation in tests as well (or force using older runners while available).

In #8 there has been discussion on how to make improvements and apple-script seemed like the easiest way to achieve these, but if MacOS 13 keeps up these errors, this would be prohibitive.

I think we could introduce a Trash object, somwething that could be used like this:

use trash::TrashExtMacOS;

let mut trash = Trash::new();
// This method is from the trait `TrashExtMacOS`
trash.set_use_finder(false);
// The following uses `recycleURLs` and so does every delete operation until `set_use_finder` is called again
trash.delete("my_file");