Command-line reference.

Every silk command, its options and its exit status. silk is the tool you type: it installs Silk versions, records release notes, and hands every other command to silkc, the compiler of the version a project pins. silk help (or silk --help) prints one line for each command, and silk help <command> (or silk <command> --help) prints that command's options. The pages after this one explain testing, formatting, diagnostics, documentation and changesets in more depth.

Commands#

CommandWhat it does
silk init [path]Create a package or a workspace, from a template or built in
silk add <path or url>Add a path dependency, or a URL dependency on a package archive, to the manifest
silk remove <name>Remove a dependency from the manifest
silk checkType-check the package for each target, without producing output
silk buildBuild the package for each target
silk run [args]Build the host executable and run it
silk debug [args]Build the host executable and start it under a debugger
silk testBuild the test runner and run the tests
silk task [name] [args]Build the package's tasks and run one, or list them
silk packCheck the package and write its release archives, documentation, checksums and signatures
silk cleanDelete the build output directory
silk planWrite compilation requests for editors and tools
silk fetchFetch every declared dependency without evaluating code
silk format [paths]Rewrite source files in the standard layout
silk lspRun the language server for an editor
silk docWrite the package's documentation as JSON
silk doctestCheck and run the Silk examples in documentation comments
silk doc-referenceGenerate the Markdown std lib reference
silk change <subcommand>Record changes, version and release the package
silk use, silk set, silk update selfInstall, pin and select Silk versions, and update the tool
silk help, silk --help, -hPrint one line for each command and exit 0
silk help <command>, silk <command> --help, -hPrint that command's usage lines and exit 0
silk --version, -vPrint silk v0.1.0 and exit 0

An unknown command prints silk: unknown command `frobnicate` and the command list, and exits 2. So does silk help frobnicate. A lone argument that is not a command is read as a Silk source file whose syntax tree to print, a debugging aid. When no such file exists, silk foo.silk prints silk: no such source file `foo.silk`; a lone argument is a command or a Silk source file to dump and the command list, and exits 2.

An option a command does not take is named, with the closest option it does take, followed by that command's usage lines; the exit status is 2:

TEXT
$ silk check --relase
silk check: unknown option `--relase`; did you mean `--release`?
usage: silk check [--manifest-path <path>] [--package <name>]... [--workspace] [--target <host|triple>]... [--release] [--optimization <none|speed|size>] [--debug true|false] [--stdlib <directory>] [--progress auto|live|plain|never] [--quiet] [--timings] [--json] [--replay <script> [--differential]]

Finding the project#

Project commands start from the current directory and walk up to the nearest silk.toml. --manifest-path <path> names the manifest directly and turns the search off.

When no manifest is found, the command stops with exit status 2:

TEXT
No silk.toml found from /home/you; run `silk init` to create a package here, or `silk init <name>` for a new folder

A manifest that has [workspace] and no [package] is a workspace root. At a root, check, build, test and doctest run every member, and format and doc cover every member. See Workspaces in Projects and packages.

Shared project options#

check, build, run and test take these options. Each may appear once unless marked repeatable.

OptionMeaning
--manifest-path <path>Use this manifest; no upward search
-p <name>, --package <name>Select a workspace member by package name. Repeatable. run takes one
--workspaceSelect every member of the enclosing workspace
--target <host|triple>Build for this target. Repeatable for check and build. run and test need a target the host can run
--releaseSelect speed optimization; use --debug to choose debug information
--optimization <none|speed|size>Choose the optimization level. --release selects speed
--stdlib <directory>Use this std lib instead of the one installed beside silk. A directory without compositions.json exits 1
--backend <llvm|direct>build and run only. direct builds a WebAssembly target without Clang. See Targets and compilation settings
--clang <path>build, run and test only. Use this Clang; a bare name is looked up on PATH. See Build outputs and native linking
--ignore-warningsLet the command succeed with warnings. Without it, a warning fails the command as an error does. See Diagnostics and silk check

Without --target, built-in commands select the host. A custom command can construct several target compilations. Targets, settings and output paths are described in Targets and compilation settings and Build outputs and native linking.

init#

TEXT
silk init [path] [--name <name>] [--lib | --workspace | --template <template> [--unsandboxed-post-init] [-- <arguments>...]]
silk init --list [template]

Creates a package in path, or in the current directory. The package name comes from the directory unless you pass --name.

FormCreates
silk init appAn executable from the official default template, silk-lang/examples/default: silk.toml, src/main.silk, .gitignore. Needs git and the network
silk init app -t <template>A package or a workspace from a template. -t is short for --template
silk init app -t minimalThe same executable, written by the compiler itself, offline
silk init --lib utilA library: src/lib.silk, kind = "library", exports = ["lib"]. Written by the compiler, offline
silk init --workspace wsA workspace root with .gitignore and one starter executable member, app: [workspace] members = ["app"]. --name names the member. Written by the compiler, offline

A template is <owner>/<repository>[/<directory>...][@<revision>] on GitHub; one segment alone, such as hello, names a directory of silk-lang/examples. A project made from a template reports the commit it came from:

TEXT
Initialized Silk project app at /home/you/app from template silk-lang/examples/default (3d330376eba6f634d1ca384269e46bc3c96727d8)

The template's [[post-init]] commands then run in the new project, in the build tool sandbox, with SILK_VERSION set to the compiler's release. On a host with no sandbox, a template with such commands is refused unless you pass --unsandboxed-post-init, which runs them with your full access. The <arguments> after -- go to each entry that sets arguments = true; a template with no such entry refuses them. --template with --lib or --workspace exits 2.

silk init --list (or -l) prints the official templates with their descriptions, or the templates of the repository or directory template names, and exits 0. See Project templates in Projects and packages.

Inside a workspace, silk init also appends the new package to the root's members:

TEXT
Initialized Silk project util at /home/you/ws/util
Added util to the workspace members in /home/you/ws/silk.toml

init refuses to overwrite an existing file and refuses a directory name that is not a valid package name; both exit 2:

TEXT
Refusing to overwrite existing project file /home/you/hello/silk.toml
Cannot derive a portable package name from Bad_Name; pass --name

A malformed template name exits 2. A template that cannot be fetched, names no directory, or whose [[post-init]] command fails exits 1, and leaves no project behind.

add and remove#

TEXT
silk add <path> [--name <name>] [--manifest-path <path>]
silk add <url> [--sha256 <hex>] [--name <name>] [--manifest-path <path>]
silk remove <name> [--manifest-path <path>]

add adds the package at path as a path dependency, after checking the dependency graph. Given an https:// or file:/// URL of a .tar.gz, .tar or ZIP archive, it downloads the archive, finds the package in it, and adds a URL dependency pinned with the archive's SHA-256, as greet = { url = "...", sha256 = "..." }. With --sha256 it refuses a download that has another SHA-256. It cannot add a git dependency; write that entry by hand. It never fetches, so a manifest whose git dependencies are not fetched yet is refused until silk check or a build fetches them. The dependency name is the package's name with - turned into _, or --name:

TEXT
Added dependency util = { path = "../util" } to /home/you/ws/app/silk.toml

remove deletes the entry, and the [dependencies] table when it becomes empty. Removing a name that is not there exits 2:

TEXT
silk: invalid dependency `util`: the package has no dependency of that name

See Dependencies in Projects and packages.

check#

TEXT
silk check [project options] [--progress <mode>] [--quiet] [--timings] [--json] [--no-server] [--replay <script> [--differential]]

Analyzes every planned target without generating code. Each target prints a heading, a row per phase and a final line, on standard error. See Diagnostics and silk check.

TEXT
Checking hello (x86_64-unknown-linux-gnu)
  load      143 modules, 1 in package         0.06s
  check     2 modules                         0.14s
  borrow    123 bodies                        0.00s
Finished hello in 0.22s
Checking hello (wasm32-wasip1)
  load      136 modules, 1 in package         0.02s
  check     2 modules                         0.08s
  borrow    79 bodies                         0.00s
Finished hello in 0.11s

That is silk check --target host --target wasm32-wasip1 on the program silk init writes.

OptionMeaning
--progress <auto|live|plain|never>How progress rows are shown. auto, the default, redraws them in place in a terminal and prints each finished row once otherwise. never prints none
--quiet, -qPrint only the final line and the diagnostics
--timingsList the five slowest modules and function bodies before the final line. Bodies are named as written, such as silk/collections/list.List<T>.appendBytes; a body inside a conformance shows it in parentheses, such as main.(Equal for Point).equals
--jsonWrite each diagnostic as one JSON object per line, with no progress output
--replay <script>Apply the edits in a TOML script in memory and print the incremental checker's counters for each step, on standard output
--differentialWith --replay, also check each step from scratch and exit 1 if the results differ
--no-serverCheck in this process only, without asking a check server or leaving one behind

The check server#

On Linux (GNU) and macOS, the last check of a silk check run that checks one package leaves a copy of itself behind, a check server. It keeps everything that check loaded and listens on a Unix socket in $XDG_RUNTIME_DIR, or in /tmp/silk-<uid> when that is not set. The socket is named after what the check depends on besides the sources: the compiler, the manifest, the build options, the standard library and the output options. The next silk check of the same project asks the server first. The server rereads the files that changed, rechecks only what the edit reaches and answers with the diagnostics and the exit status, usually in a few hundredths of a second. A served check prints no phase rows:

TEXT
$ silk check
Checking hello (x86_64-unknown-linux-gnu)
  load      166 modules, 1 in package         0.03s
  check     2 modules                         0.10s
  borrow    237 bodies                        0.00s
Finished hello in 0.13s
$ silk check
Checking hello (x86_64-unknown-linux-gnu)
Finished hello in 0.00s

A changed manifest, or a file added to or removed from the package, makes the server decline and exit; that check runs by itself and leaves a new server. A server exits after 15 minutes with no check, and sooner when its project is removed or reshaped. A workspace check (--workspace, or several members) leaves no server. Other hosts never start one. --no-server checks in the process alone, which is what to use when comparing timings or when memory is short.

build#

TEXT
silk build [project options] [--backend llvm|direct] [--unsandboxed-tools] [--progress <mode>] [--quiet] [--timings] [--costs]

Builds every planned target. The rows add codegen and link, and the final line names the program, relative to the current directory, or in full when it is outside it, as from inside a workspace member:

TEXT
Compiling hello (x86_64-unknown-linux-gnu, dev)
  load      143 modules, 1 in package         0.03s
  check     1 module                          0.00s
  codegen   689 functions                     0.28s
  borrow    229 bodies                        0.01s
  link      clang                             0.36s
Finished build/x86_64-unknown-linux-gnu/dev/hello in 0.71s

--progress, --quiet and --timings work as for check. --timings also lists the slowest functions to emit. --unsandboxed-tools lets package tool steps run without the operating-system sandbox for this one command; see Build plans and generated code.

--costs charges what the build generated to the calls in your package that asked for it: the functions generated, their LLVM text and the static evaluation steps, with the time they took:

TEXT
  Costliest calls: functions generated, their LLVM text, static evaluation steps, time
        19   41.7 KB     2,986   12.2ms  src/main.silk:9:7  Effect.log("Hello, world!\n", &()) |> Effect.provideMut(&mut logger)
         1     433 B         0   0.04ms  src/main.silk:7:20  StdoutLogger.make()
  Calls in this package asked for 20 of the build's 362 functions (42.1 KB of 845.1 KB); static evaluation ran 3,410 steps in all. Time varies from run to run; the other columns do not.

Use the counts to decide where generic code or static evaluation is worth trimming; the times vary between runs.

A package whose src/tasks.silk has a Build variant runs that command instead; see Tasks and build graphs.

run#

TEXT
silk run [project options] [--backend llvm|direct] [--progress <mode>] [--quiet] [--coredump <path>] [arguments...] [-- arguments...]

Builds the executable and runs it in the current directory. On a WASI target it runs the module with wasmtime; see Targets and compilation settings. The build prints the same progress output as silk build, on standard error, and ends with Finished before the program starts or Failed when it does not build. Standard output carries only the program's output. --progress and --quiet work as for check.

Options are read up to --. Any argument that does not start with -, and every argument after --, is passed to the program in order. The exit status is the program's own. A program whose main returns 7 makes silk run exit 7. A build that fails exits 1, or 2 when Clang is missing or the construct is not supported yet, and the program does not start.

TEXT
$ silk run --quiet -- Ada
Finished build/x86_64-unknown-linux-gnu/dev/hello in 0.78s
Hello, Ada!

At a workspace root, run runs the only executable member. With two or more, pass -p. A library cannot run:

TEXT
Cannot run library artifact

On a WASI target, silk run sets WASMTIME_BACKTRACE_DETAILS=1 for Wasmtime, unless the environment already sets it, so a trap's trace shows each frame's source line. --coredump <path> has Wasmtime write a core dump to path when the program traps. It needs a WASI target, and the path cannot contain a comma; otherwise the command stops before the build with status 2:

TEXT
silk: `--coredump` needs a WASI target; a native program dumps core as the system configures
silk: the `--coredump` path cannot contain a comma

See Debugging.

debug#

TEXT
silk debug [project options] [--progress <mode>] [--quiet] [--port <[address:]port>] [arguments...] [-- arguments...]

Builds the executable as run does and starts it under a debugger, with the program's arguments read the same way.

  • On a native target it replaces itself with LLDB, as lldb -- <program> [arguments...]. LLDB is SILK_LLDB, else lldb on PATH. Without one, the build finishes and the command stops with silk: `debug` needs lldb on PATH or SILK_LLDB (exit 2).

  • On a WASI target it runs wasmtime run -g <port>, Wasmtime's debugger stub, which waits for LLDB before the program starts. --port takes a port or address:port; the default is 1234. Attach from LLDB with process connect --plugin wasm connect://127.0.0.1:1234.

--port matters only on WASI, and debug takes no --coredump. Use a build with debug information, such as the default dev build, so the debugger sees Silk names, lines and variables. See Debugging.

test#

TEXT
silk test [project options] [--root <path>] [--file <path>] [--filter <text>] [--timeout <seconds>] [--no-cache]

Builds the test runner as build/<target>/<mode>/<package>-tests and runs the selected tests. When nothing the runner was built from has changed, the next run reuses it instead of building it again. Every run executes every selected test.

OptionMeaning
--root <path>Discover tests from this module instead of the package root
--file <path>Run only tests declared in this source file
--filter <text>Run only tests whose module::name contains the text, ignoring ASCII case
--timeout <seconds>Fail a test that runs longer than this; 60 by default, 0 for no limit
--no-cacheBuild the runner again even when nothing changed

--root and --file name files of one package, so in a workspace they need -p. A Test variant can define the project's test graph; the built-in test command otherwise uses the standard options.

task#

silk task [compiler options] <command> [command options] builds the root package's tasks.silk and invokes its TaskSet. With no command it lists available variants. Dependencies contribute modules and static plans; their task entries never run.

build, run, test and plan each have a built-in. A root variant with that name replaces it. A reserved command without a variant runs its built-in. Commands embed standard Options. silk plan writes requests without compiling graph roots.

The task receives SILK_PROJECT_ROOT, SILK_INVOCATION_DIRECTORY, SILK_COMPILER and SILK_STDLIB. Task.silk invokes the same compiler. A command that compiles its graph uses Build.compile, Compilation.build or Build.write.

plan#

TEXT
silk plan [project options] [--unsandboxed-tools] [--backend llvm|direct]

Writes the compilation requests a build would compile, without compiling them: one TOML file per compilation in build/requests/, named <name>.<target>.<mode>.toml, and build/requests/plan.json, which lists them. Editors read these files to check code with the same settings a build uses. A Plan variant in src/tasks.silk replaces it. See The plan command and editors in Tasks and build graphs.

Requests#

silkc resolve --definition <file> --output <file> freezes a compilation definition into a versioned request. silkc compile --request <file|-> consumes it without manifest discovery, network fetching or plan evaluation. silkc request-schema prints its derived JSON Schema; silkc manifest-schema prints the manifest schema.

silk package-path --manifest <file> --dependency <alias> --path <subpath> resolves an explicitly included dependency file and prints its absolute path as a JSON string.

fetch#

silk fetch [--manifest-path <file>] downloads all declared dependency pins, including workspace members and transitive dependencies, for offline work. It does not evaluate plans, compile source or run tasks.

pack#

TEXT
silk pack [--list] [--output <dir>] [--json] [--bin] [--sign <file>] [shared project options]
silk pack --new-key <path>

pack checks the package as check does, then writes its release files in build/package/, or --output: the source archive <name>-<version>.tar.gz, the documentation <name>-<version>.docs.json, and SHA256SUMS. --bin also builds each target's executable, as a release build unless --optimization or --debug chooses otherwise, and writes <name>-<version>-<target>.tar.gz. --sign <file>, or the key text in SILK_SIGNING_KEY, writes a minisign <file>.minisig beside every file. --new-key <path> writes a new key pair and packs nothing. --list prints the files the source archive would hold and writes nothing.

TEXT
wrote /home/you/greet/build/package/greet-0.1.0.tar.gz (4 files, 432 bytes)
sha256 b9b86606bfddde5c73ded12c082aca71c9578b9d09c42f7646202a29051367e2
wrote /home/you/greet/build/package/greet-0.1.0.docs.json

A package that does not check, has no version, has a path dependency, or sets publish = false is refused with exit status 1; a signing key that cannot be read exits 2 before anything is written. In a workspace it packs every member that does not set publish = false. See Packaging releases in Projects and packages.

clean#

TEXT
silk clean [--manifest-path <path>]

Deletes the build output directory and prints Removed /home/you/hello/build. At a workspace root it deletes the shared output directory. When there is nothing to remove, it prints Nothing to clean: /home/you/hello/build does not exist and still exits 0.

format#

TEXT
silk format [paths] [--check] [--manifest-path <path>]

Formats every .silk file under the package's source root, or only the given files and directories. --check reports files that need formatting and changes nothing. Put -- before a path that starts with -. See Formatting.

lsp#

TEXT
silk lsp [--stdlib <directory>]

Runs a language server that speaks the Language Server Protocol over standard input and output. An editor starts it; you do not run it by hand. It reports diagnostics as you type, lists the declarations in a file, folds blocks, and formats the file the way silk format does. Hover and go to definition work on the names you use and declare, from your package or the std lib, and signature help on the call you type. Inlay hints show the type of each let binding. Completion, find references, rename and workspace symbol search work over the package. See Editor setup in Get started.

doc, doctest and doc-reference#

TEXT
silk doc [--manifest-path <path> | --stdlib] [-o <json>] [--include-private] [--target <triple>] [--stdlib-root <directory>]
silk doctest [--manifest-path <path>] [--target <triple>] [--stdlib-root <directory>]
silk doctest (-i <json> | --stdlib) [--source-root <directory>] [--target <triple>] [--stdlib-root <directory>]
silk doc-reference [--stdlib-root <directory>] -o <directory> [--check]

-o is short for --output and -i for --input. silk doc --help, silk doctest --help and silk doc-reference --help print these lines. silk doc warns on standard error about each documentation link that names no declaration. A link to a private declaration resolves only with --include-private. See Doc tests and reference generation.

change#

TEXT
silk change [--dir <path>] patch|minor|major "Summary" [--migration "Guidance"]
silk change [--dir <path>] status [--tag <name>]
silk change [--dir <path>] version [--tag <name>]
silk change [--dir <path>] release [--json]
silk change [--dir <path>] snapshot --commit <sha> [--dev <n>] [--json]
silk change [--dir <path>] since [version|dependency] [--to <version>] [--from <version>] [--source <path>] [--json]
silk change [--dir <path>] recover

silk change --help prints the full usage with notes. The silk tool runs these itself, whatever version the project pins. See Changesets and releases.

Silk versions#

TEXT
silk use [--json]
silk use <version> [--dev] [--json]
silk use list [--json]
silk use which [--json]
silk use uninstall <version>
silk set <version> [--dev] [--no-install] [--json]
silk update self [--dev]
silk +<version> <command> [args]

Silk ships as two programs. silk is the tool, the command you type, and the installer puts it on your PATH. silkc is the compiler, one per installed version. The tool manages the Silk versions installed side by side in $SILK_HOME/toolchains/<version> (SILK_HOME defaults to ~/.silk) and runs every other command, unchanged, with the silkc of the version the directory selects: silk build is silkc build from the pinned version. The compilers are not on your PATH, so editors, scripts and habit always reach the pinned one. When nothing selects a version, the tool runs the silkc in the same folder as itself, which is how a release archive, Homebrew or mise works without ~/.silk.

Each installed version is a release archive unpacked as is, without its bin/silk: bin/silkc beside lib/silk/stdlib. No command prompts. Results go to standard output, and --json prints one JSON object instead. silk --help prints the usage with notes, and silk --version prints the version the directory selects, as silk v0.1.0. When SILK_HOME is unset and HOME names no existing directory, commands that need the store exit 1 with silk: cannot find the toolchain directory; set SILK_HOME to an absolute path, or HOME to an existing directory.

CommandWhat it does
useInstall the version this project pins. Leaves your default alone. Exits 2 where nothing is pinned
use <version>Install that version and make it your default, used outside projects and by silk init. Never edits a project
use listEvery installed version, newest first. * marks the one selected here; tags say pinned here and default
use whichThe selected version, why it was selected, and the path of its silkc. Exits 3 when it is not installed
use uninstall <version>Delete that version's directory
set <version>Pin the project to that version in silk.toml. Downloads nothing
update selfReplace the tool with the one from the newest release. Installs no Silk version

A version is a release such as 0.1.0 or 0.1.0-dev.11, latest (the newest stable release) or dev (the newest release, dev releases included); latest --dev is the same as dev. Until a stable release is published, latest names nothing: silk use latest exits 1 with silk: no stable Silk release is published yet; `latest --dev` names the newest dev release. use <version> and set always write the full version, build metadata included.

TEXT
$ silk use list
* 0.1.0-dev.14+0066f03c8c33  (pinned here, default)  /home/you/.silk/toolchains/0.1.0-dev.14+0066f03c8c33/bin/silkc
$ silk use which
0.1.0-dev.14 (package silk-version in /home/you/app/silk.toml)
/home/you/.silk/toolchains/0.1.0-dev.14+0066f03c8c33/bin/silkc
$ silk use which --json
{"version":"0.1.0-dev.14","origin":"package","manifest":"/home/you/app/silk.toml","installed":true,"path":"/home/you/.silk/toolchains/0.1.0-dev.14+0066f03c8c33/bin/silkc","install":"silk use"}

A version released before the compiler was named silkc holds only bin/silk, the compiler; the tool runs that one instead.

Which version a command runs#

The tool picks a version before every command it forwards. The first of these that is set wins:

Originwhich saysJSON origin
silk +<version> <command>selected with +<version>command-line
SILK_TOOLCHAINselected by SILK_TOOLCHAINenvironment
[workspace].silk-version of a workspace that lists the packageworkspace silk-version in <manifest>workspace
[package].silk-version of the nearest silk.tomlpackage silk-version in <manifest>package
default in $SILK_HOME/settings.tomldefault in settings.tomldefault

silk-version = "0.0.0" pins nothing. A version without build metadata, such as 0.1.0-dev.11, matches the newest installed build of it, such as 0.1.0-dev.11+6de14da2a8a6.

The tool then replaces itself with that version's silkc, passing the arguments unchanged without the +<version>, and sets SILK_TOOLCHAIN to the full version and SILK_HOME. It never reads a forwarded command's options, so a compiler command the tool does not know still works.

When the selected version is not installed, the command does not run. It exits 3:

TEXT
$ silk build
silk: Silk 0.1.0-dev.10+3934b61998da (package silk-version in /home/you/app/silk.toml) is not installed.
Install it with: silk use

When nothing selects a version and no silkc sits beside the tool, it also exits 3, with silk: no Silk version is selected here: no project pins one and there is no default. Install the newest Silk as the default with: silk use latest. A + argument that is not a semantic version is a usage error, exit 2:

TEXT
$ silk +garbage build
silk: `+garbage` is not a Silk version; +<version> takes a semantic version such as +0.1.0-dev.11

A silk-version the tool cannot read, such as a form a newer tool understands, is a configuration error, exit 2, ending with A newer tool may read it; update silk with: silk update self. The tool never guesses what such a pin means.

With SILK_AUTO_INSTALL=1 in the environment, or auto-install = true in $SILK_HOME/settings.toml, a missing version is installed first, with the notice silk: installing Silk <version> (auto-install is on) and the install output on standard error, so the command's own output stays alone on standard output. This install does not change your default.

silk lsp behaves differently, because an editor starts it. When the version is missing, the tool prints the same lines on standard error and then serves a minimal language server: it answers initialize with no capabilities, shows the message in the editor with window/showMessage, answers other requests with a MethodNotFound error, and exits 0 after shutdown and exit.

use#

use downloads silk-<version>-<target>.tar.gz, its .minisig signature and native-seed.json from the silk-lang/silk GitHub releases, over HTTPS. Before installing, it checks:

  • the archive is signed by the Silk release key, and the trusted comment reads silk v<version> <archive name>;

  • the compiler bin/silkc has the SHA-256 that native-seed.json names for the host target;

  • the archive holds the compiler and lib/silk/stdlib and no path outside its top folder.

It unpacks into a hidden staging folder in $SILK_HOME/toolchains and renames it into place only when every check passes, so a failed or interrupted install leaves nothing. Installs hold a lock on $SILK_HOME/.install.lock, so two at once download a release once. Installing a version that is already there downloads nothing. Inside a project that pins another version, use <version> adds a note on standard error saying how to move the project with silk set.

A version without build metadata is resolved to its newest published build, which needs the GitHub release listing. A full version does not.

SILK_TOOLCHAIN_MIRROR names an absolute directory to install from instead of GitHub, for machines without access to it. It holds one v<version> folder of release assets per release, and the same checks apply. A relative path is refused with exit status 1: silk: SILK_TOOLCHAIN_MIRROR must be an absolute directory path. A tampered archive is refused with exit status 5:

TEXT
silk: silk-0.1.0-dev.14+0066f03c8c33-x86_64-unknown-linux-gnu.tar.gz is not signed by the Silk release key: the signature does not match the file

set#

set writes silk-version into the [workspace] table of the workspace that lists the package, or into the package's own [package] table, and moves the members' own pins along with a workspace pin. Then it installs the version it pinned, with the same download and signature checks as use:

TEXT
$ silk set 0.1.0-dev.72
Pinned Silk 0.1.0-dev.72+9c780a04d6ef in /home/you/app/silk.toml ([package].silk-version, was 0.1.0-dev.73+a4ea55e44e78)
Installed Silk 0.1.0-dev.72+9c780a04d6ef in /home/you/.silk/toolchains/0.1.0-dev.72+9c780a04d6ef
note: Silk 0.1.0-dev.72+9c780a04d6ef is older than this tool (0.1.0-dev.73+a4ea55e44e78); if it cannot read this silk.toml, pin a newer version or edit the manifest for it

The note goes to standard error. A version that is already installed downloads nothing and prints no Installed line. The install runs before any file is written, so a failed download (exit status 4) or a failed signature check (exit status 5) leaves the project unchanged.

--no-install only pins, downloads nothing, and so also works offline for a full version:

TEXT
$ silk set 0.1.0-dev.73 --no-install
Pinned Silk 0.1.0-dev.73+a4ea55e44e78 in /home/you/app/silk.toml ([package].silk-version, was 0.1.0-dev.72+9c780a04d6ef)
Silk 0.1.0-dev.73+a4ea55e44e78 is not installed yet. Install it with: silk use

--json prints one object instead, with version, manifest, table, previous, members, changed, installed (true once the version is there) and downloaded (true when this run fetched it). Outside a project, set exits 2 with silk set: no silk.toml here or above; start a project with `silk init`. A version with no published release exits 1 with silk: no published Silk release is version 0.1.0-dev.999. set refuses 0.0.0.

uninstall#

TEXT
$ silk use uninstall 0.1.0-dev.14
Removed 0.1.0-dev.14+0066f03c8c33
It was your default; choose another with: silk use <version>
This project pins it (package silk-version in /home/you/app/silk.toml), so its commands stop until you reinstall it with: silk use
$ silk use uninstall 0.5.0
0.5.0 is not installed; nothing to remove

update#

silk update self takes the newest stable release (the newest dev release while none is stable, or always with --dev), checks its archive's signature, and replaces $SILK_HOME/bin/silk with its bin/silk. It installs no Silk version, and leaves a tool that is already as new alone, saying silk 0.1.0 is up to date (newest release: 0.1.0). This and the installer are the only ways the tool changes; it never updates itself on its own.

silk update silk changes nothing and exits 2, because Silk versions are installed side by side rather than updated:

TEXT
$ silk update silk
silk update silk: Silk versions are not updated in place.
To install the newest Silk as your default: silk use latest
To move this project to it and install it: silk set latest

Exit status of the tool#

StatusMeaning
0Success, including a command that changed nothing
1Failure: no toolchain directory, a mirror that cannot be read, a version that cannot be removed, a release without the silk tool for update self
2Usage or configuration error: unknown subcommand or option, a version that is not a semantic version, use or set with no project, a pin the tool cannot read
3The selected version is not installed, or nothing selects one. Any forwarded command can exit 3 this way
4A download failed
5A release failed verification

Single-file forms#

Two lower-level forms compile one root module directly. They still need a silk.toml in the source file's directory or above it, which supplies the package context. Without one, both stop with exit status 2:

TEXT
No silk.toml found from /home/you/loose; run `silk init` to create a package here, or `silk init <name>` for a new folder
TEXT
silk build <source> -o <output> [--emit final|llvm-ir|llvm-bitcode|assembly|object] [--target <triple>] [--clang <path>] [--stdlib <directory>] [--optimization none|speed|size] [--backend llvm|direct] [--debug true|false] [--stats]
silk test <root> -o <executable> [--stdlib <directory>] [--filter <text>] [--file <path>] [--timeout <seconds>] [--optimization none|speed|size] [--debug true|false] [--no-cache]

--emit picks the output stage: llvm-ir writes LLVM text, the whole-program module the executable would link, and object an object file. With --debug true and --optimization none, the LLVM text carries the line tables as !dbg metadata and each parameter and let binding as a #dbg_declare record. --optimization names the Clang optimization directly: none (-O0), speed (-O2) or size (-Oz). The source file must sit below the package's source root; when that folder does not exist, both forms stop with silk: invalid source root (exit 1). --stats prints compiler query counters. Diagnostics print the same way as silk check prints them, and a successful build prints one Compiled line. Paths in that line are relative to the current directory, or absolute when the file is outside it:

TEXT
$ silk build bad.silk -o out
/home/you/demo/bad.silk:1:31: error[SEM0129] Return expected i32 but received bool
$ silk build good.silk -o out
Compiled good.silk -> out (llvm, x86_64-unknown-linux-gnu, 243 symbols)

With SILK_RECEIPTS set in the environment, a failed build prints each diagnostic as a SILK_BUILD_ERROR= JSON record with the code, byte span and module instead, for tools that read them.

Exit status#

StatusMeaning
0Success. For format --check: every file is already formatted
1The work ran and failed: compile errors, a failing test, a --file or --filter that matched no test, files that need formatting, a failing doc test, stale reference pages, a --stdlib that is not a std lib, a bad native link input, any silk change error including a malformed silk change command line
2The command could not start: a malformed command line (it names the argument it refuses, suggests the closest option for a misspelled one, and prints the command's usage lines), an unknown command, no manifest, an invalid manifest (including an unknown key, such as a removed [profiles] table), an executable built with runtime = { kind = "none" } that exports no C main, an unknown target, an unknown workspace member, a source file or folder named silk or Intrinsic, a dependency or exports problem, conflicting options, a refused init, add or remove, a Clang that is missing or does not start, a construct the compiler does not support yet
3, 4, 5From the tool: the selected version is not installed, a download failed, or a release failed verification. See "Exit status of the tool"
othersilk run only: the program's own status. silk debug exits with the debugger's status

In a workspace, each member gets a status and the command exits with the worst one: 2 over 1 over 0.

Environment variables#

VariableUsed for
PATHFinding clang, git (to fetch git dependencies) and the silk tool
SILK_CLANGThe Clang executable, when --clang is not given. Clang itself runs with only PATH, HOME, TMPDIR, TMP, TEMP, LANG, LC_ALL and LC_CTYPE from the environment (and SystemRoot, USERPROFILE and LOCALAPPDATA on Windows), so a --clang wrapper script does not see SILK_CLANG
SILK_LLVM_ARThe archiver for static libraries; default is llvm-ar beside Clang
SDKROOT, DEVELOPER_DIRmacOS SDK selection; an invalid SDKROOT is an error
SILK_PROGRESSThe progress style for check, build and run when --progress is not given: auto, live, plain or never. An invalid value is ignored
NO_COLORSet to a non-empty value, turns off colors in live progress output
COLUMNSThe width of live progress output; default 80
TERMdumb turns live progress output into plain rows
SILK_RECEIPTSSet, makes the single-file silk build print diagnostics as SILK_BUILD_ERROR= JSON records
SILK_ARCHIVE_MIRRORSpace-separated <prefix>=<replacement> entries: an archive URL that starts with a prefix is fetched with the longest matching prefix replaced by an https:// or file:/// URL. The pinned SHA-256 is still checked
SILK_OFFLINESet, a build that needs a [native.archive.<name>] archive or a URL dependency it has not fetched fails instead of downloading it
SILK_SIGNING_KEYThe text of a minisign secret key file, for silk pack to sign with when --sign is not given
SILK_SIGNING_PASSWORDThe password of an encrypted signing key, for silk pack; with --new-key, encrypts the new key
SILK_NO_TOOL_SANDBOXSet, the host behaves as one with no sandbox for build.silk tool steps, so they are refused unless the invocation explicitly passes --unsandboxed-tools
SILK_PROFILE_GENERATEA directory: native builds pass -fprofile-generate=<dir> to Clang, for profile-guided optimization. See Targets and compilation settings
SILK_PROFILE_USEA merged .profdata file: native builds pass -fprofile-use=<file> to Clang
SILK_WASMTIMEThe wasmtime that silk run, silk debug and silk test use on a WASI target; default wasmtime on PATH
WASMTIME_BACKTRACE_DETAILSPassed to Wasmtime by silk run, silk debug and silk test on a WASI target, set to 1 when the environment does not set it, so trap traces show source lines
SILK_LLDBThe LLDB that silk debug starts for a native program; default lldb on PATH
SILK_WASM_TOOLSThe wasm-tools that builds a wasm32-wasip2 component; default wasm-tools on PATH
SILK_WASI_ADAPTERThe Preview 1 command adapter, wasi_snapshot_preview1.command.wasm, that a wasm32-wasip2 executable needs
SILK_WASI_REACTOR_ADAPTERThe Preview 1 reactor adapter, for a wasm32-wasip2 component without a main
SSL_CERT_FILEThe certificate bundle for silk change since and silk use when they fetch releases over HTTPS
SILK_HOMEFor the tool: where versions, bin/silk and settings.toml live; default ~/.silk. Must be an absolute path. For the compiler: git dependencies are checked out in $SILK_HOME/git, or $HOME/.silk/git when it is unset, pinned native archives and URL dependencies are kept in $SILK_HOME/archives, and $SILK_HOME/native-overrides.toml overrides archives for the machine
SILK_TOOLCHAINFor the tool: the version to run, overriding the project's pin. The tool sets it to the full version it runs
SILK_AUTO_INSTALLFor the tool: 1 installs a missing selected version before running the command
SILK_TOOLCHAIN_MIRRORFor the tool: an absolute directory of release assets to install from instead of GitHub
HOME, TMPDIR, TMP, TEMP, LANG, LC_ALL, LC_CTYPEPassed through to Clang; no other variable is
HTTP_PROXY, HTTPS_PROXY, NO_PROXY, ALL_PROXY (and lowercase), SSH_AUTH_SOCK, GIT_SSH_COMMAND, SSL_CERT_FILE, SSL_CERT_DIR, GIT_SSL_CAINFO, XDG_CONFIG_HOMEPassed through to git when it fetches a git dependency, with PATH, HOME, USER, TMPDIR, LANG and LC_ALL; no other variable is. GIT_TERMINAL_PROMPT=0 is set, so git never prompts

The installer reads SILK_HOME, SILK_RELEASE and SILK_CHANNEL; see Install. The std lib is found at lib/silk/stdlib beside the bin directory that holds silkc, following symbolic links.

Output streams#

Test results, --replay lines, formatted and unchanged go to standard output. Progress rows, diagnostics, refusals, warnings, needs formatting, and SILK_GAP notices go to standard error. silk run prints its build's progress rows on standard error and leaves standard output to the program, which writes to both as it chooses. silk test prints no progress rows.

View the source of this page