typst / typst/typst

CLI command for installing a package locally

Open
#4,484 12 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cli feature request packages
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

Add basic package management to the typst cli to be able to add a package from a package directory or (ideally) a zipped package (.tpz?) and make it available to the @local namespace. The command line interface could be like this:

typst pkg install ./my-package-dir

or

typst pkg install ./my-package-bundle.tpz

This would ease the distribution of internal packages as well as package development, as it avoids having to know the details of where to copy the package ( {cache-dir}/typst/packages/local/ , or was it {data-dir}/typst/packages/{namespace}/{name}/{version}? or even an overridden location by env vars) and knowing the mapping between the package format and the package repository structure.

I suggested this feature previously in issue #3099 (https://github.com/typst/typst/issues/3099#issuecomment-2141873547 and https://github.com/typst/typst/issues/3099#issuecomment-2146864535 ) but that issue deals with other aspects of the @local namespace not directly related to this use case. That also included typst pkg new my-new-pkg-dir for basic scaffolding but this is orthogonal to this feature.

This uses the @local namespace as documented here https://github.com/typst/packages?tab=readme-ov-file#local-packages

Use Case

Many organizations have templates (and could use packages) that are not suitable for publication in the open due to privacy and other reasons. Also, package and template developers may want to only publish more or less finished versions of a package.

Currently, to use such templates or packages a user has the following options:

  • copy the package dir along the Typst document using it and do the imports with relative paths
  • do a manual install of the package, to a platform specific location (could be env var specific) and use the @local namespace in imports
  • install the third party typst package installer

The first one feels a bit clumsy and the second one is not very kind on normal users and need a lot of direction from the package/template author to get running.

The proposed solution would allow installing the package using 'typst pkg install your-new-fancy-pkg.tpz' and afterwards use '#import "@local/fancy-pkg:0.1.0": template' on your document.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typst CLI package-management entry point and the documented @local package layout. Compare the proposed directory and .tpz inputs with the existing local package repository structure and the locations or environment overrides described in the issue. Done means a user can install either supported package form with typst pkg install and import the result through @local.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.