Convert REQUIRE to Project.toml and Manifest.toml


Is there a standard process or function that allows one to upgrade old packages using the REQUIRE file to the new package format using Project.toml and Manifest.toml ?

Apologies if I missed this documentation online.



This is what I do:

  1. Steal the format from an existing Project.toml, e.g., and create your own Project.toml in your repository.
  2. You probably only need “name” and “uuid” in the top section, so you can delete the rest or change it for your package if you want.
  3. Replace the package name there with your package name.
  4. Get a uuid for your package using using Pkg; Pkg.METADATA_compatible_uuid(pkg_name) where pkg_name is the name of your package as a String without .jl (watch your spelling!).
  5. Replace the uuid in the Project.toml and delete the list of deps there, keeping the header. Save the file!
  6. cd into the repository of the package, most likely in your .julia/dev/pkg_name folder.
  7. In a Julia session, run ]activate .
  8. Open the REQUIRE file in another window.
  9. Run ]add dep_name for all your dependencies in the REQUIRE file. This will automatically update the Project.toml and Manifest.toml, creating the latter if it doesn’t exit.
  10. You may want to add an extra [compat] section as shown in to support certain versions of packages or Julia.
  11. Add your test dependencies as well and then copy the test deps’ lines from the Project.toml file’s [deps] section to the [extras] section, and list the package names in the [targets] section as shown in

And now you should be having Project.toml and Manifest.toml files in your repo. Apparently, you still need to keep your REQUIRE files there for registered packages. Anyways after doing the above, you can close that Julia session and open a new one in the default v1.0 environment, and pretend like none of this had to happen. Hopefully, some expert can correct me if I got something off.


Developing and using my own code
What's the use a Project.toml file and the the use of a Manifest.toml in a Julia project?

Here is my quick-and-dirty Julia function to automate a similar workflow:


Generate Project.toml file for the existing current project at `\$PWD`.
It activates the generated Project.toml and then adds packages based on
function generate_project_toml(name::AbstractString = guess_project_name())
    if isfile("Project.toml")
        error("Project.toml exists.")

    if !isfile("REQUIRE")
        error("REQUIRE file not found.")
    deps = read_require("REQUIRE")

    pkg = Base.identify_package(name)
    project_toml = """
    name = $(repr(name))
    uuid = "$(pkg.uuid)"
    write("Project.toml", project_toml)

    @info "Activating \$PWD (to run `Pkg.add`)"

    guess_project_name() :: String

Guess project name using Git.  It works even in worktree repository.
function guess_project_name()
    path = abspath(rstrip(read(`git rev-parse --git-dir`, String)))
    prev = ""
    while path != prev
        if basename(path) == ".git"
            return basename(dirname(path))
        prev, path = path, dirname(path)
    error("Project not found")

function read_require(path)
    deps = String[]
    for line in readlines(path)
        name, = split(line)
        if name == "julia"
        push!(deps, name)
    return deps


I used tkf’s functions (thanks!), but had to ask for more help to resolve “core” package dependency issues including LinearAlgebra, Statistics, Random, Test, etc. Maybe it has already been mentioned somewhere but I missed it. Turns out the fix is easy and just noting it here for documentation’s sake:

Start Julia with working directory in the project repo, for example cd ~/.julia/dev/MyPkg. After running generate_project_toml("MyPkg") here, open the package manager ]; then type activate .. This should show (MyPkg) pkg>, and now add the missing packages such as add LinearAlgebra Statistics .... This will append to the deps section in Project.toml and resolve issues you might discover in Travis.

Aside: make sure the MyPkg/.travis.yml file is also updated to the newer script: format:

1 Like


Can you specify on point 10? I can’t find anything about [compat] in that link