cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Unable to open cheat sheet on Ubuntu 22.10

Open MartinRykfors opened this issue 3 years ago • 8 comments

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.

MartinRykfors avatar Feb 13 '23 18:02 MartinRykfors

Ugh. We moved it there because we thought that'd work for snaps.

Are there docs on what is allowed?

auscompgeek avatar Feb 13 '23 22:02 auscompgeek

This is what I am able to find in the snapcraft docs: https://snapcraft.io/docs/home-interface

The home interface 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.

MartinRykfors avatar Feb 14 '23 09:02 MartinRykfors

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()?

auscompgeek avatar Feb 14 '23 10:02 auscompgeek

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.

AndreasArvidsson avatar Feb 14 '23 11:02 AndreasArvidsson

Can it be within a hidden directory within documents directory? I guess we could just make it non-hidden in documents directory if not 🤷‍♂️

pokey avatar Feb 14 '23 11:02 pokey

I can give it a go later today to see if a hidden directory in documents would work (if I remember to).

MartinRykfors avatar Feb 14 '23 11:02 MartinRykfors

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"

MartinRykfors avatar Feb 14 '23 20:02 MartinRykfors

Nice! PR created #1273

AndreasArvidsson avatar Feb 15 '23 00:02 AndreasArvidsson