Package Management System
YaoXiang includes a package manager that provides declarative dependency management, version locking, and workspace support.
Current Capabilities
Dependency source availability is inconsistent, so check this table before getting started:
| Source | Declaration | Status |
|---|---|---|
| Workspace member | { workspace = "key" } | ✅ Available; preferred for local multi-package projects |
| Git repository | { git = "<url>" } | ✅ Available; currently the only cross-repository channel |
| Official registry | name = "1.0.0" | ⛔ Not yet implemented; see below |
| Local path | { path = "../lib" } | ⚠️ Known issue: cannot use after installation; see below |
Official Registry Not Yet Open RFC-014a has ruled that the official registry server,
authentication, and yank are indefinitely postponed. Therefore:
yx publishwithout arguments fails immediatelyyx add <bare package name>writes to the manifest, but the subsequentyx installwill necessarily fail:
$ yx add http
✓ Added dependency 'http' (*)
$ yx install
⚠ 1 dependencies failed to install:
http - registry source not implemented (RFC-014a); use a git or path dependency
Error: Failed to install dependenciesAlways use --git for external package dependencies. For publishing, use yx publish --github; see Publishing. :::
Local Path Dependencies Are Currently Unavailable yx add --path can write the
dependency to yaoxiang.toml and yaoxiang.lock, but it does not place the package in the vendor directory. The subsequent use <package-name> then reports E5001.
Use a workspace for local multi-package projects—it is designed for this use case and is fully functional. This issue is tracked separately. :::
Getting Started: Local Multi-Package Projects
The following workflow has been tested end to end and can be copied as-is.
1. Create the Workspace Root
The workspace root directory needs a yaoxiang.toml:
mkdir my-project && cd my-project# my-project/yaoxiang.toml
[workspace]
members = { }An empty members is allowed—the init command below automatically registers entries in it.
2. Create a Member Under the Root
yx init mylib --lib
yx init appWhen init detects a workspace in a parent directory, it automatically registers the member. There is no need to edit the root manifest manually:
✓ Registered to workspace (key 'mylib')
✓ Created library project 'mylib'After registration, the root manifest becomes:
# my-project/yaoxiang.toml
[workspace.members]
app = "app/yaoxiang.toml"
mylib = "mylib/yaoxiang.toml"
[workspace.dependencies]members Values Are Manifest File Paths The value of members must point to a
yaoxiang.toml file, not a directory. Using "app" produces the misleading error nested workspace is not supported. :::
Verify the registration:
$ yx workspace list
Workspace my-project (2 members)
app 0.1.0 (app/yaoxiang.toml)
mylib 0.1.0 (mylib/yaoxiang.toml)3. Write the Library Implementation
The src/lib.yx generated by yx init --lib contains only comments and no code, so you need to fill it in:
// mylib/src/lib.yx
greet: () -> String = "hello from mylib"All top-level bindings are visible externally by default, so pub is unnecessary—see the Module System.
4. Declare the Dependency in the Application
A member references a sibling member with { workspace = "<key>" }, where key is the name used during registration:
# my-project/app/yaoxiang.toml
[package]
name = "app"
version = "0.1.0"
description = "demo app"
[dependencies]
mylib = { workspace = "mylib" }5. Install and Run
# Run from the workspace root
yx install
$ yx install
✓ Resolved 0 dependencies:
mylib (workspace:mylib)
Updated yaoxiang.lock// my-project/app/src/main.yx
use std.io
use mylib
main = () => {
io.print(mylib.greet())
}$ yx run app/src/main.yx
hello from mylib
runmust be executed inside the project directory. Runningrunon a single.yxfile outside the project silently produces no output.
Getting Started: Dependencies on External Repositories
For cross-repository dependencies or any Git source, use --git:
yx init app
cd app
# Add the dependency
yx add some-lib --git https://github.com/example/some-lib
# Install
yx install
$ yx install
✓ Resolved 1 dependencies:
some-lib (0.1.0) [Installed]After installation, the package is placed in .yaoxiang/vendor/<package-name>-<version>/ and can be used with use:
use some_libSpecify a Version
Use the -v / --version option for versions; it is not a positional argument:
yx add some-lib --git https://github.com/example/some-lib --version "^0.1.0"Writing yx add some-lib 0.1.0 reports unexpected argument.
Pin a Branch or Tag
Write the ref in the Git URL's query string, rather than adding a branch field to the manifest:
yx add some-lib --git "https://github.com/example/some-lib?branch=dev"
yx add some-lib --git "https://github.com/example/some-lib?tag=v1.0.0"
yx add some-lib --git "https://github.com/example/some-lib?rev=abc1234"Dependencies pinned this way are reported as pinned by yx outdated and are excluded from version comparisons.
The branch Field in the Manifest Is Ineffective Writing
some-lib = { git = "...", branch = "dev" } neither produces an error nor takes effect—the dependency is still resolved from the default branch. The ref must be passed through the URL query string. :::
Supported version specifications:
| Syntax | Meaning |
|---|---|
1.0.0 | Exact match (not caret) |
* | Any version |
^1.0.0 | Caret; allows upgrades within the minor version |
~1.0.0 | Allows patch-version upgrades |
>=1.0.0, <2.0.0 | Lower and upper bounds |
1.* | Segment-level wildcard |
>=1.2.3, <2.0.0 | Comma-separated combination |
1.2 and 1 are automatically expanded to 1.2.0 and 1.0.0.
Manifest Files
yaoxiang.toml
[package]
name = "my-project" # Required
version = "0.1.0" # Required
description = "项目描述" # Required when publishing
authors = ["作者 <a@b.c>"]
license = "MIT"
repository = "https://github.com/org/repo" # Required for --github publishing
[dependencies]
some-lib = { git = "https://github.com/example/some-lib", version = "^0.1.0" }
[dev-dependencies]
test-utils = { git = "https://github.com/example/test-utils" }The workspace root instead uses a [workspace] section:
[workspace.members]
app = "app/yaoxiang.toml"
mylib = "mylib/yaoxiang.toml"
[workspace.dependencies]
# Versions are pinned centrally here; members inherit them with { workspace = true }yaoxiang.lock
Automatically generated by the package manager, commit it to version control:
# Automatically generated by the YaoXiang package manager
version = 1
[package.mylib]
version = "0.1.0"
source = "workspace"vendor Directory
Dependencies are placed under the project's .yaoxiang/vendor/ directory:
.yaoxiang/
└── vendor/
├── std/ # Standard library interface files
└── some-lib-0.1.0/ # Third-party dependency; directory name = <package-name>-<version>The .gitignore generated by init already includes .yaoxiang/, so there is no need to add it manually. Delete the entire .yaoxiang/ directory and run yx install again to rebuild it.
Command Reference
yx init
yx init [NAME] [--lib]When NAME is omitted, the current directory name is used. --lib generates a library project (src/lib.yx, with empty content); otherwise, it generates src/main.yx.
Artifacts: yaoxiang.toml, yaoxiang.lock, .gitignore, tests/, and .yaoxiang/vendor/std/.
yx add
yx add <DEP> [--git <GIT> | --path <PATH>] [-v <VERSION>] [-D]| Option | Description |
|---|---|
--git <URL> | Git source; must be specified explicitly for cross-repository dependencies |
--path <P> | Local path; see the known issue above |
-v, --version | Version specification |
-D, --dev | Adds the dependency to dev-dependencies |
--trust | Trusts the package's build.yx |
Without --git or --path, the command falls back to the registry source, which has not yet been implemented.
yx install / update / rm / list
yx install # Resolve and download according to the manifest, then write the lock file
yx update [PKG] # Update all without arguments; update only the specified package with a name
yx rm <DEP> [-D] # Remove a dependency
yx list # List dependencies and their sourcesyx outdated
yx outdatedChecks whether dependencies have newer versions. This currently works for the default branch of Git sources. Path and workspace sources are skipped, while dependencies pinned to a tag, branch, or rev are reported as pinned.
yx clean / yx cache clean
yx clean # Clean build artifacts and packages in vendor that are not referenced by the lock file
yx cache clean # Clear the global package cacheyx workspace
yx workspace list # List members
yx workspace add <PATH> [--as KEY] # Register an existing package as a member
yx workspace remove <KEY> # Deregister the member (the directory is retained)Command Differences Between the Root and Member Directories The workspace root
manifest has no [package] section, so list, outdated, and update report missing field package when run in the root directory. Run these commands inside a member directory. install, workspace, publish, cache, and clean are available in the root directory. :::
Publishing
Local Validation and Packaging
cd mylib
yx publish --dry-runPrerequisite: [package].description is required; otherwise, the command reports 发布要求 [package] 提供 description.
$ yx publish --dry-run
Running pre-publish tests…
No tests found.
✓ Packed mylib/target/yxpkg/mylib-0.1.0.yxpkg (SHA-256 47a2c83…)Process: run the [tool.test] tests (--no-test skips them) → materialize workspace references as ^version → package the .yxpkg → calculate the SHA-256. The entire process makes zero network requests.
Publish to a GitHub Release
This is currently the only available distribution channel:
# 1. Create and push the tag first—publish does not create it for you
git tag v0.1.0
git push origin v0.1.0
# 2. Configure the repository URL
# Set [package].repository in yaoxiang.toml, or ensure that the git remote origin exists
# 3. Provide the token
export YX_GITHUB_TOKEN=<your-token>
# 4. Publish
yx publish --githubThe target repository is determined by [package].repository, with git remote origin as the fallback. Publication is rejected if a Release with the same name already exists; the tag must already exist.
Consumers can import the package through a Git source:
yx add mylib --git https://github.com/org/repo --version "^0.1.0"Currently Unavailable
The following capabilities belong to the official registry, which has not yet been implemented, and must not be included in dependency declarations: bare yx publish, yx login / logout, yank, third-party registries, and --registry <url>.
Troubleshooting
registry source not implemented
The dependency is a bare package name. Use --git to specify a Git source; see Dependencies on External Repositories.
E5001: module not found
- The dependency is not installed—run
yx installin the workspace root or member directory. - A local path dependency was used—switch to a workspace.
- This is a module path issue rather than a dependency issue—see Module System Troubleshooting.
missing field package
You ran list / outdated / update in the workspace root directory. Enter a member directory and run the command there.
nested workspace is not supported
The value of [workspace.members] points to a directory. Change it to the manifest file path, such as "app/yaoxiang.toml".
