# Ubuntu Linux + Racket 8.10 snap + Emacs racket-mode

**URL:** <https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263>\
**Category:** General\
**Tags:** today-i-learnt\
**Created:** [August 31, 2023, 8:52am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263 "2023-08-31T08:52:26Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [August 31, 2023, 8:52am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/1 "2023-08-31T08:52:26Z")

</div>

I spent some time figuring out this behavior and I thought it might be useful to others:

On an Ubuntu Linux machine, I installed Racket 8.10 as a snap, and everything was working fine, except `racket-mode` in Emacs. The Racket files for `racket-mode` would fail to load in `racket` or `raco` with a "permission denied" error.

It turns out that snaps don't have access to configuration files in the user's home directory, and this means that they don't have access to files inside the `.emacs.d` folder, where `racket-mode` was installed.

Moving racket mode to a non-"dot folder" solved the problem. I moved mine in `~/site-lisp/racket-mode`.

Hopefully this info is useful to others. Also, if you have this setup working without the above workaround, I would like to know the details.

Alex.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [August 31, 2023, 11:34am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/2 "2023-08-31T11:34:14Z")

</div>

This sounds like [install and racket-run permission denied · Issue #654 · greghendershott/racket-mode · GitHub](https://github.com/greghendershott/racket-mode/issues/654) when Racket is a Snap.

See also [racket-documentation-search doesn't work with snap browsers in default configuration · Issue #620 · greghendershott/racket-mode · GitHub](https://github.com/greghendershott/racket-mode/issues/620) when Firefox or other web browser is a Snap.

(Possibly also a problem when Emacs is a Snap??)

* * *

In my experience with VMs and containers, there's usually an option to make outside dirs accessible. (IIUC even just read-only would suffice, here).

But it seems like Snap sandboxes don't make that possible, or at least easy (e.g. `--classic` might help if you use command-line instead of GUI Snap store)?

I've been hoping someone who knows more about Snaps might discover an easy recipe (EDIT: that allows people to keep using things like MELPA to install Emacs packages in the default place under `~/.emacs.d/`).

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [August 31, 2023, 11:51am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/3 "2023-08-31T11:51:45Z")

</div>

p.s. I updated that issue with a detail you contributed -- it looks like the issue is dotfile dirs, not the home dir per se.

---

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [August 31, 2023, 11:51am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/4 "2023-08-31T11:51:58Z")

</div>

The issue you linked does look similar to the problem I experienced.

I forgot to mention it in my original post, but I installed Racket Snap with the `--classic` flag and it still didn't have permissions to read from the dot-folders.

I also have Emacs installed as a Snap, but it has no permission errors when it tries to access files.

Alex.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [August 31, 2023, 12:18pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/5 "2023-08-31T12:18:43Z")

</div>

@alexh I wonder if [changing the Emacs packages directory](https://www.gnu.org/software/emacs/manual/html_node/emacs/Package-Files.html) from the default `~/.emacs.d/elpa` to (say) `~/emacs-packages` would help? (That way `racket` wouldn't be trying to read `.rkt` files out of a dot dir.)

So I guess:

- `mv` any existing `~/.emacs.d/elpa` files there
- early in your `init.el` (before any `package-xxx` stuff) set `package-user-dir` to there
- restart Emacs

(If this works, it would have some bonus justification: it's always felt weird to me that Emacs package files go under `~/.emacs.d` by default -- they feel like "cache" not "config", e.g. when excluding subdirs for backup and stuff like that.)

---

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [August 31, 2023, 10:34pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/6 "2023-08-31T22:34:34Z")

</div>

I installed `racket-mode` directly from the Github repository (I do that with some other packages), so moving `elpa` would not help me directly, however, it might be good advice for those who use it.

I'm not an expert on Snaps, but I noticed that Emacs installed as a Snap is able to access, and defaults to reading, the `~/.emacs.d/init.el` file, but Racket installed as a Snap (even with `--classic` flag), can only access files in the user's home directory but not in dot-directories. It also creates its own separate mounting point, so its own config files are in a separate location under the users `~/snap` folder.

Alex.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [September 1, 2023, 1:42pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/7 "2023-09-01T13:42:20Z")

</div>

@alexh Is [https://snapcraft.io/emacs](https://snapcraft.io/emacs) the Emacs Snap you installed?

If so, its description says [GitHub - alexmurray/emacs-snap: GNU Emacs in a snap](https://github.com/alexmurray/emacs-snap) is its source definition.

As a wild a$$ guess, its use of [`confinement:classic`](https://github.com/alexmurray/emacs-snap) seems relevant?

@samth the description for [https://snapcraft.io/racket](https://snapcraft.io/racket) doesn't list its source (maybe good to add that?) and I can't seem to find a repo for it either under you or Racket on GitHub. Where is it?

What do you think about `confinement:classic`?

EDIT: p.s. Oh, I guess the `--classic` command line flag might be equivalent(ish?) to running as if the config were `confinement:classic`?

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [September 1, 2023, 6:13pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/8 "2023-09-01T18:13:15Z")

</div>

The snap source is here: [zygoon / racket-snap · GitLab](https://gitlab.com/zygoon/racket-snap)  
It's maintained by @zyga

I've added some of that information to the snap page.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [September 2, 2023, 12:53pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/9 "2023-09-02T12:53:08Z")

</div>

Thanks for the link!

- The Racket snap uses `strict` confinement: [snapcraft.yaml · main · zygoon / racket-snap · GitLab](https://gitlab.com/zygoon/racket-snap/-/blob/main/snapcraft.yaml#L14). Maybe because...

- Snaps using `classic` confinement need human review to get on the snap store. [https://snapcraft.io/docs/reviewing-classic-confinement-snaps](https://snapcraft.io/docs/reviewing-classic-confinement-snaps).

- Note: IIUC the `--classic` command line flag does _not_ make a `strict` snap more permissive. Instead it's just user confirmation (they know they're installing an already-`classic` snap).

* * *

@zyga Should the Racket snap change to use `classic` confinement instead (and maybe @samth could help with store review)??

(OR if strict confinement is a desired feature -- maybe this snap is intended for e.g. students or hobbyists exploring Racket and they want a sandbox -- that's cool. But then maybe the snap and snap yml description and snap store descriptions should explain that intent, and link to [https://download.racket-lang.org/](https://download.racket-lang.org/) as an alternative??)

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [September 6, 2023, 7:01pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/10 "2023-09-06T19:01:15Z")

</div>

Anyway/meanwhile I made an FAQ in a pinned issue: [FAQ: "permission denied" when running your Racket program · Issue #666 · greghendershott/racket-mode · GitHub](https://github.com/greghendershott/racket-mode/issues/666)

---

<div class="post-metadata">

**Author:** ![zyga](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/zyga/32/585_2.png) [@zyga](https://racket.discourse.group/u/zyga)\
**Post date:** [November 30, 2023, 7:05pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/11 "2023-11-30T19:05:48Z")

</div>

> [@greghendershott](#):
>
> @zyga Should the Racket snap change to use `classic` confinement instead (and maybe @samth could help with store review)??

Apologies for the late reply. I've started looking into this. I think that we can make the snap to work with classic confinement and then request it through the snap-store "store requests" category. Racket would fall under the compilers/IDEs permission so I think this should be granted.

As to what existing users should do, I think it makes sense to keep both versions around, one with strict confinement and one with classic confinement, and allow people to choose with tracks. It remains to be see which should be default.

EDIT: I've filed a snap store request at: [Request for classic confinement of racket - store-requests - snapcraft.io](https://forum.snapcraft.io/t/request-for-classic-confinement-of-racket/37971)

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [November 30, 2023, 8:03pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/12 "2023-11-30T20:03:51Z")

</div>

Thanks!

> [@zyga](#):
>
> As to what existing users should do, I think it makes sense to keep both versions around, one with strict confinement and one with classic confinement, and allow people to choose with tracks. It remains to be see which should be default.

I got the impression that even when the snap specifies "classic" (weak) confinement, the user must opt into this with the `--classic` flag. Otherwise it's still strict. (At least with command-line install; not sure about GUI "software store" UX.)

Assuming that's true (?), a single "classic" snap would serve both roles -- still defaulting to strict, and allowing the user to opt into "classic".

p.s. Caveat: I've only read online docs. I have just a little hands-on experience with "universal package formats", and that little experience is mostly with flatpaks not snaps.

---

<div class="post-metadata">

**Author:** ![zyga](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/zyga/32/585_2.png) [@zyga](https://racket.discourse.group/u/zyga)\
**Post date:** [November 30, 2023, 8:07pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/13 "2023-11-30T20:07:30Z")

</div>

> [@greghendershott](#):
>
> I got the impression that even when the snap specifies "classic" (weak) confinement, the user must opt into this with the `--classic` flag. Otherwise it's still strict. (At least with command-line install; not sure about GUI "software store" UX.)

That's not quite like it. To _install_ a snap that uses classic confinement you have to pass `--classic` option to `snap install`. Snaps using classic confinement are incompatible with being used with strict confinement due to how the mount namespace looks like for both.

The idea I'm currently exploring is to have both snaps - classic and strict - available under different channels. One can install or switch channels with the `--channel` argument, for example (hypothetical): `snap install --classic --channel=classic/stable racket` vs `snap install racket`. We can invert where the classic snap would be published (we could have a `strict` channel instead).

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [November 30, 2023, 8:46pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/14 "2023-11-30T20:46:40Z")

</div>

Ah OK.

I should probably stay out of the details. 😄

I'd just like to make a _gentle_ pitch that the default channel, or path of least resistance, give people the classic, unconfined thing if possible. (Why: 1. Selfishly, it might make my life a little easier. 2. Generally, it seems appropriate for a programming language, as opposed to say a productivity app.)

However, if you believe it's better for the default to be confined, or anyway it's just too late to change that on the snapcraft repo -- no worries! Once it settles down I can write documentation to explain whatever the new situation is. And thanks again for looking at this!

---

<div class="post-metadata">

**Author:** ![zyga](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/zyga/32/585_2.png) [@zyga](https://racket.discourse.group/u/zyga)\
**Post date:** [November 30, 2023, 8:49pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/15 "2023-11-30T20:49:13Z")

</div>

I don't know yet. I see your point and it _does_ make sense. I need to get things to work first though.

---

<div class="post-metadata">

**Author:** ![zyga](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/zyga/32/585_2.png) [@zyga](https://racket.discourse.group/u/zyga)\
**Post date:** [December 1, 2023, 8:21am UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/16 "2023-12-01T08:21:29Z")

</div>

I have a working version with classic confinement. I've pushed my branch to [Files · classic · zygoon / racket-snap · GitLab](https://gitlab.com/zygoon/racket-snap/-/tree/classic?ref_type=heads) and I'm working on [Request for classic confinement of racket - #4 by zyga - store-requests - snapcraft.io](https://forum.snapcraft.io/t/request-for-classic-confinement-of-racket/37971/4) to allow this through the store.

I believe the classically confined version should be the default, with strict confinement being available in a separate channel.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [December 1, 2023, 10:33pm UTC](https://racket.discourse.group/t/ubuntu-linux-racket-8-10-snap-emacs-racket-mode/2263/17 "2023-12-01T22:33:38Z")

</div>

re the discussion there about additional criteria: You make a good point about the open-ended nature. As support: The Racket main distribution and packages repo has many examples, including using Unix domain sockets, making systemd daemons, userspace FUSE filesystems, ....
