Workspaces - how?

Workspaces, described in the 1.12 announcement, sound useful, but after reading this and any documentation I could find they are still mysterious to me. How do I make a workspace and use it? Do I edit the Project file directly? Are there Pkg commands? What is the file layout? Is there any actual documentation anywhere that I missed?

2 Likes

Does this help: 11. Project.toml and Manifest.toml · Pkg.jl ?

Not at all (I already read that). It answers none of my questions, but serves as a great example of documentation that doesn’t work. It’s entirely in the passive voice (“A workspace is defined in the base project by giving a list of the projects in it”: two passive constructions in a single sentence, leaving the reader in the dark: is defined how, and by whom?).

2 Likes

By you. By adding the section [workspace] to the Project.toml file that is at the top level.

Like this:

[workspace]
projects = ["test", "docs", "benchmarks", "PrivatePackage"]

Which would require that the subfolders “test”, “docs”, “benchmarks”, “PrivatePackage” exist, and that in each of these folders is a Project.toml file for the sub-project.

What is still unclear? Do you have sufficient information to try it out?

1 Like

Thank you, that helps. I’ll try it out.

1 Like

What’d I’d really like to know is how monorepos with many packages are registered, and how Pkg resolved and installed them before workspaces.

You can read more about mono repos here:

Since 1.11, a Project.toml has the “Sources” section (11. Project.toml and Manifest.toml · Pkg.jl), so that you can add unregistered dependencies in a portable way.

Note that the sub-projects cannot be more than one sub-folder deep, otherwise you have to get there by intermediate projects. There is a PR to lift that restriction: allow specifying projects in a workspace more than one level under it by KristofferC · Pull Request #59849 · JuliaLang/julia · GitHub