Skip to content

Package installations interfer when multiple Typst instances are running #2739

Closed

Description

@sitandr

Description

One may resonably believe that compiling Typst is a "clean" operation, so it should be okay to run several compiling jobs at the same time. In fact, that works perfectly until packages are involved.

When compiling several documents that use a package that isn't installed yet, both Typst processes start downloading this package, but some of processes fail with messages like this one:

downloading @preview/cetz:0.1.2
 45.9 KiB /  45.9 KiB (100 %)  45.9 KiB/s in  0s ETA:  0s
error: file not found (searched at C:\Users\andr\AppData\Local\typst/packages/preview/cetz/0.1.2\typst.toml)
  ┌─ \\?\C:\Users\andr\Desktop\projects\typstlike\typst-examples-book\src\packages\typst-src\05a1dbe2a2d17e5e81991406bed640775db6ab4ce2d585bc5a0d1175def43ea1.typ:4:8
  │
4 │ #import "@preview/cetz:0.1.2": canvas, draw
  │         ^^^^^^^^^^^^^^^^^^^^^

Note: in the end, package is installed correctly, so recompilation fixes it all.

This isn't a really important thing, of course. There are several ways to avoid this error, but I think it would be nice if Typst could "lock" package directories to make such errors impossible.

P.S. The error is currently observed both on Windows and Linux.

Reproduction URL

No response

Operating system

No response

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Nov 22, 2023
  2. added
    cli
    packages
    on Nov 22, 2023
  3. added
    urgent
    on Jul 16, 2024
  4. Andrew15-5 commented on Jul 31, 2024

    @Andrew15-5
    Contributor

    I'm on it.

  5. removed
    urgent
    on Sep 16, 2024
  6. m-haug commented on Feb 17, 2025

    @m-haug

    Sorry for the initial double post.

    As I noted in the other issue, this race may lead to consistently broken builds, where Typst seems to assume the package is installed correctly while it is in some corrupted state. Even repeated compilations (of individual documents, so no further race condition) do not solve the issue.

    I still have to experiment, but I think with sufficiently bad luck, you may actually convince Typst that the package exists in the local cache and isn't a package at all. I will update this when I manage that.

    EDIT: The best I've managed so far has been this error, which happens consistently until the broken package is removed from the cache.

    error: file not found (searched at C:\Users\Markus Haug\AppData\Local\typst/packages\preview/valkyrie/0.2.2\src\lib.typ)
      ┌─ \\?\C:\Users\Markus Haug\tests\typst\parallel-package-downloads\document.typ:1:8
      │
    1 │ #import "@preview/valkyrie:0.2.2" as z
      │         ^^^^^^^^^^^^^^^^^^^^^^^^^
    

    While it may seem similar at first blush, the error for a non-existent package (version) differs.

  7. laurmaedje commented on Feb 23, 2025

    @laurmaedje
    Member

    I opened #5935, which is a similar problem. Maybe #5935 (comment) could be a fix for both?

  8. Andrew15-5 commented on Feb 23, 2025

    @Andrew15-5
    Contributor

    We still have to do some locking for this issue, regardless of the target/temporary location.

    Actually, see #5935 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclipackages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions