Mops - on-chain package manager for Motoko!

Mops updates

CLI release 1.1.0

Run mops self update to update Mops CLI to the latest version.

  • New mops watch command to check for syntax errors, show warnings, run tests, generate declarations and deploy canisters (docs)

  • New flag --no-toolchain in mops install command to skip toolchain installation

  • New lock file format v3 (docs)

  • Faster mops install from lock file when lock file is up-to-date and there are no cached packages

  • Fixed replica test hanging in watch mode bug

  • Fixed mops failing when dfx is not installed

  • Fixed mops test Github Action template

More information of package dependencies and dependents

On the package page, in the “Dependencies” tab, you can see how old is a dependency and the latest available version of the dependency.

In the “Dependents” tab, you can see which version of a package a dependent package uses.

Same blog post

4 Likes

Hey really love what you’re doing there with mops. Two questions on my usage so far:

  1. I’m developing a project that is using the ic.http_request feature which is supported in pocket-ic since 5.0.0 (Releases · dfinity/pocketic · GitHub) will support for pocket-ic > 4.0.0 come to mops anytime soon? Or should i work-around that limitation? Any suggestions

  2. When using Debug.print("Some log"); and running mops test with pocket-ic the messages don’t appear by default in the output, nor does --reporter verbose Instead I’ve created a wrapper shell script at ~/.cache/mops/pocket-ic/4.0.0/pocket-ic that writes the output into a log file which i’m then tailling. That feels super hacky – what is a better approach?

Cheers!

1 Like

Please share your OS and Node.js versions.

This test also doesn’t print anything?

import Debug "mo:base/Debug";
import Time "mo:base/Time";

actor {
	public func runTests() : async () {
		Debug.print(debug_show(Time.now()));
	};
};

Please try mops 1.1.2-pre.0 and dfx 0.24.1

npm i -g ic-mops@1.1.2-pre.0

Then remove pocket-ic from mops.toml and run test with --replica pocket-ic. It will run pocket-ic replica that comes with dfx

1 Like

Unfortunately not:

Regarding versions:

$ mops -v
CLI 1.1.1
API 1.3
$ dfx --version
dfx 0.24.0
$ node -v
v22.9.0
$ cat /etc/issue
Ubuntu 24.04.1 LTS \n \l

There is a server variable to output canister logs in pic.js so I think it is exposed via the server. There is also a switch for pocket ic logs. They are separate.

@ZenVoich running the same test with the newer versions shows the debug message:

2 Likes

Mops CLI updates

Run mops self update to update Mops CLI to the latest version.

Release 1.2.0

  • Removed mops transfer-ownership command

  • Added mops owner command to manage package owners (docs)

  • Added mops maintainers command to manage package maintainers (docs)

  • Added experimental support for pocket-ic replica that comes with dfx in mops test command (docs)

  • Added flag --verbose to mops test command to show replica logs

  • Fixed bug where mops watch would fail if dfx.json did not exist

  • Fixed bug with local dependencies without mops.toml file

Release 1.1.2

  • Fixed {MOPS_ENV} substitution in local package path

Multiple package owners and maintainers support

Now each package can have multiple owners and maintainers. Owners have full access to the package, while maintainers can only publish new versions.

On “Versions” tab you can see who published each version of the package.

Documentation:

Package registry fixes

Fixed scrolling to definition in package documentation.

Fixed automatic assignment of package category based on package keywords.

4 Likes

Hi @ZenVoich I get a stack overflow error when I try to add a local dependency that is outside of my current directory. For example,

mops add ../dep
mops install

returns the following error

RangeError: Maximum call stack size exceeded

node:path:1256
  join(...args) {
      ^

RangeError: Maximum call stack size exceeded
    at Object.join (node:path:1256:7)
    at bY (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:152:61967)
    at l0 (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:152:63251)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130759)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)
    at Q (file:///home/vmr/.npm-global/lib/node_modules/ic-mops/cli.js:170:130825)

Node.js v23.9.0

I am only successfully able to add a local project when it is a child of the current one.

Please, share your mops.toml and ../dep/mops.toml

I know this is a trivial example but I cannot make it work.

lib/test/mops.toml

[package]
name = "test"
version = "1.0.0"
description = "test"
repository = "test"
keywords = [ "test" ]
license = "MIT"

[dependencies]
dep = "../dep"

lib/dep/mops.toml

[package]
name = "dep"
version = "1.0.0"
description = "test"
repository = "test"
keywords = [ "test" ]
license = "MIT"

Indeed, there are was a bug with local dependencies.

Fixed in 1.7.1

Please, update mops cli and try again

mops self update
2 Likes

It is working now. Thank you for the quick fix!

I think there is a similar problem in the Motoko VSCode add-in. I am getting the following error from the server but I am able to compile and deploy the code without issues. I am not sure whom I should ask to investigate?

[Error - 9:13:02 PM] Error while parsing Motoko with deps, retrying
[Error - 9:13:02 PM] Error: file "/home/vmr/icp/lib/arrays/src" (for package `arrays`) does not exist
    at Y0 (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/motoko.js:6:60)
    at Object.parseMotokoWithDeps (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/motoko.js:6:2509)
    at mZ._updateWithFileText (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21366:10580)
    at mZ.notify (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21366:11461)
    at /home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21817:8600
    at Array.forEach (<anonymous>)
    at M (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21817:8536)
    at ue (/home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21817:6814)
    at /home/vmr/.vscode-oss/extensions/dfinity-foundation.vscode-motoko-0.17.3-universal/out/server.js:21817:6571
    at Array.forEach (<anonymous>)

I was able to get the language server to work correctly by adding my local package folder to the VSCode workspace, based on comments from @rvanasa Unrecognized imports outside of VS Code workspace · Issue #305 · dfinity/vscode-motoko · GitHub

2 Likes

Mops Registry

Mops on-chain registry has reached 200 Motoko packages! :rocket:

Mops CLI cumulative updates

Run mops self update to update Mops CLI to the latest version.

1.8.0

  • Add mops format command for formatting Motoko source files with Prettier and Motoko plugin (docs)

  • Add --format flag to mops watch command to enable automatic formatting during watch mode (docs)

1.7.2

  • Fix replica termination in mops test command

1.7.1

  • Fix mops install for local dependencies

1.7.0

  • Add support for actor class detection to run replica tests in mops test command

1.6.1

  • Fix mops i alias for mops install command (was broken in 1.3.0)

1.6.0

  • Add support for .bash_profile and .zprofile files to mops toolchain init command

1.5.1

  • Collapsible output of mops bench in a CI environment

  • Fix regression in mops bench without dfx.json file (by @rvanasa)

1.5.0

  • Compile benchmarks with --release flag by default

  • Respect profile field in dfx.json for benchmarks

1.4.0

  • Update mops bench command output:

  • Print only final results if benchmarks run in a CI environment or there is no vertical space to progressively print the results

  • Hide “Stable Memory” table if it has no data

  • Hide verbose output when running in a CI environment (“Starting replica…”, “Running simple.bench.mo…”, etc.)

  • Add LaTeX colors to the diffs when running in a CI environment with --compare flag

  • CLI now fails if excess arguments are passed to it

1.3.0

  • Show error on mops install <pkg> command. Use mops add <pkg> instead.

  • Added support for pocket-ic replica that comes with dfx in mops bench command. To activate it, remove pocket-ic from mops.toml and run mops bench --replica pocket-ic. Requires dfx 0.24.1 or higher.

  • mops init now pre-fills package name with current directory name in kebab-case

  • Updated non-major npm dependencies

3 Likes

A package manager on ICP… this is something awesome and worthwhile, coming from a previous Linux user myself (Ubuntu, Mint, Manjaro/Arch). Windows users might not understand the lingo, but I understand the developer perspective working with many different package managers. While I didn’t scroll through every message here, I admire the ability of someone extending the capabilities of canisters by allowing for managed applications on your platform. Whatever you do to make it easier for developers, including seamless update implementation, ease of automating updates while preserving data, and ease of searching for new packages to implement, you have my support, whatever worth that is.

So, Mops looks like the standard for canister package management, and I have yet to see any competition. Thank you for making this and more power towards making it better and better.

4 Likes

Mops Updates

Summary

  • Mops CLI updates (v1.9.0)
  • Package documentation coverage displayed on package pages
  • Documentation coverage comparison between package versions
  • Package documentation markdown rendering
  • GitHub dependencies restriction

Mops CLI v1.9.0 updates

Run mops self update to update Mops CLI to the latest version.

New Documentation Commands

Mops CLI v1.9.0 introduces powerful new documentation tools to help package authors improve their code documentation:

mops docs generate

Generate documentation for your Motoko packages using mo-doc.

Documentation

mops docs coverage

Analyze the documentation coverage of your package. This command scans through your Motoko code and provides detailed statistics about which functions, types, and vars have documentation comments.

These commands help ensure your packages are well-documented and provide a better developer experience for users of your packages.

Documentation

Documentation Coverage on Package Pages

Starting with packages published using CLI v1.9.0, the Mops package registry now displays documentation coverage information directly on package pages. This gives developers immediate insight into how well-documented a package is before they decide to use it.

The coverage percentage is calculated based on the ratio of documented public functions, types, and vars to the total number of public API elements in the package.

Documentation Coverage Diff Between Versions

When viewing different versions of a package, you can now see how documentation coverage has changed between versions. This helps track improvements in package documentation over time and encourages maintainers to continuously improve their documentation.

Package Documentation Markdown Rendering

Package documentation containing markdown tables and admonition boxes is now displayed correctly.

This didn’t work before because Mops stores documentation in asciidoc format, but developers mostly use markdown comments for documentation.

Before:

After:

GitHub Dependencies Restriction

To improve dependency resolution reliability and ensure more stable package ecosystems, the Mops registry now prohibits publishing packages that have GitHub dependencies in their regular [dependencies] section.

Existing packages with GitHub dependencies will continue to be available in the registry, but new packages with GitHub dependencies will not be allowed to be published.

What this means:

  • :cross_mark: Prohibited: GitHub dependencies in [dependencies] section
  • :white_check_mark: Allowed: GitHub dependencies in [dev-dependencies] section

Why this change:

  • Ensures more reliable dependency resolution
  • Prevents cascading failures from unavailable GitHub repositories
  • Encourages use of stable, versioned packages from the Mops registry
6 Likes

Great documentation updates :purple_heart:

Is there a specific reason or case that prompted this? There are still a significant number of Motoko and mops packages with dependencies that are outside the mops ecosystem. Therefore, it would be nice to continue to allow packages that use those dependencies to be pushed to mops but just flag them as such to have a lighter push towards using mops packages only.

The fewer packages that have github deps the more features we can implement that rely on mops registry, such as version ranges, or backend deps resolver.
Existing packages with github deps will continue to work, its just restriction for new publications.

Perhaps this is too sudden decision. We can enable it for some packages, or mark them, or make it just a warning not a blocker, depending on the case…

Of the last 40 new packages published, only 1 has a github dependency.