How to compile locally with imports?

I am using Typst again, have not for a while. Importing packages used to work.

I have Typst 0.13.1 installed.
Compiling works with tinymist compile main.typ, but not with typst compile main.typ. I also tried to set the root directory to the home directory, but that did not work.
The tinymist version I use also has Typst version 0.13.1.
The error message is

typst compile main.typ
error: failed to load file (access denied)
  ┌─ main.typ:1:8
  │
1 │ #import "@preview/touying:0.6.1": *
  │         ^^^^^^^^^^^^^^^^^^^^^^^^
  │
  = hint: cannot read file outside of project root
  = hint: you can adjust the project root with the --root argument

I have verified that the package is correctly downloaded to
/home/asmund/.cache/typst/packages/preview/touying/0.6.1.
I am on Ubuntu 24.04.2 LTS if that is relevant.

Hello. What is the code that does not compile? How many Typst files in the project?

Just the one file. It fails on line one.
Making a new file with only the one following line:

#import "@preview/touying:0.6.1"

Fails with the same error message.

Importing some other package does not work either, for example

#import "@preview/js:0.1.3"

also fails the same way.

Did you by any chance install Typst via snap? The Typst snap package currently can’t access the directories where local or cached packages are stored, so that might be the issue.

3 Likes

Thanks, I did install via snap.
I will try installing from another source tomorrow.