How to rebuild toml files?

My package under development has the file structure MyPackage/src and MyPackage/examples. My development process has been:

julia> using Revise
pkg> dev .
pkg> activate ./examples
julia> include("./examples/first_example.jl")

which used to work, but now Revise has started giving error messages like:

ERROR: LoadError: failed to find source of parent package: <some name of a dependent package>

I am thinking that the toml files may have been corrupted, so I would like to delete them and start over. I was hoping to use ] generate MyPackage to generate new toml files, but this does not work because the package manager wants to create a new directory structure with MyPackage and MyPackage/src rather than reuse my existing directories that are populated with my code. So the question is: what command can I use to re-initialize the toml files? Or is there a better way to clear this error from Revise?

So examples has it’s own Project.toml file? Maybe something is outdated/out-of-sync? You could try running ]resolve after environment activation to have Pkg check the dependencies. Maybe also try ]precompile (but I think resolve triggers precompilation if it’s necessary).

I don’t know what causes the error from Revise though. Never seen it before.

I think it would very rarely be the best way to solve a problem but if you have to reset a Project.toml file, open it in an editor and remove everything after the first section. This keeps the identity of a package/project but removes all dependencies, etc.

To reset a Manifest.toml file, simply delete it and let Pkg regenerate it. This is a much more useful operation and frequently the best resolution if you have a merge conflict in the Manifest.

I think ]resolve basically does that. There is an important difference on earlier Julia versions if you have packages that are not in General. This information was stored exclusively in Manifest.toml and thus it could not be regenerated from Project.toml alone. Since 1.11 Project.toml can contain a [sources] section tracks the foreign locations, so Manifest.toml probably can be regenerated nowadays.
Still I think ]resolve is the better way generally. But I don’t know exactly what is ment by “a merge conflict in the Manifest”.

With a merge conflict I mean the result you get if you do a git merge of two branches with diverging updates of Manifest.toml.

]resolve is less powerful than deleting the Manifest if you have managed to get into an inconsistent state. E.g. try to remove an arbitrary dependency entry in Manifest.toml and see how unhappy Pkg becomes.

1 Like

Thanks for explaining :slight_smile: I never had that happen to me ever so just tried it and have to agree that in this case there seems no other way then to delete the Manifest. Good to keep in mind in case it happens to me in the future.