Unable to open cheat sheet on Ubuntu 22.10
Running the command cursorless cheat sheet will make Firefox try to open the generated cheat sheet file. However, in more recent versions of Ubuntu, Firefox will be unable to open this file due to being run as a snap package, which disallows it from opening files within hidden directories.
When Firefox fails to open the cheat sheet, it presents the user with a page stating the following:
Access to the file was denied The file at /home/rykarn/.cursorless/cheatsheet/index.html is not readable. It may have been removed, moved, or file permissions may be preventing access.
Stackoverflow explanation snapd issue
By changing src/cheatsheet/cheat_cheet.py, line 48 to use the directory ~/cursorless/cheatsheet instead of ~/.cursorless/cheatsheet, the cursorless cheat sheet makes Firefox successfully show the cheat sheet page on my system.
From the linked discussion on snapd it seems that this problem is not present in the current LTS version of Ubuntu, but it will likely start manifesting more often once people upgrade to later versions of it.
Ugh. We moved it there because we thought that'd work for snaps.
Are there docs on what is allowed?
This is what I am able to find in the snapcraft docs: https://snapcraft.io/docs/home-interface
The
homeinterface allows access to non-hidden files owned by the user in the user’s home ($HOME) directory where a user normally stores their personal files and documents.
So maybe having the option to pollute the home directory with a non-hidden cursorless directory could be a workaround.
Perhaps we should shove it in the Documents directory? We'd have to work out what that is though since that's user-configurable. Could use platformdirs.user_documents_dir()?
Another solution that we talked about is to have a setting for where the cheat sheet should be located, but if this will hit all ubuntu users in the future a more robust solution is to be preferred.
Putting it in the documents directory is a good solution I believe.
Can it be within a hidden directory within documents directory? I guess we could just make it non-hidden in documents directory if not 🤷♂️
I can give it a go later today to see if a hidden directory in documents would work (if I remember to).
Using~/Documents/.cursorless/cheatsheet as the cheatsheet directory actually did work! Firefox made no complaint and was able to open it.
I changed line 48 to this:
cheatsheet_out_dir = Path.home() / "Documents" / ".cursorless" / "cheatsheet"
Nice! PR created #1273