I’m trying to figure out how environments work in Julia. My understanding is that it creates a new empty package space where I can add different packages and work in isolation from other environments.
So I create my new environment and avtivate it and when I execute Pkg.status() I get an empty list, as I expect. However, when I execute using somepackage where somepackage is a package that needs adding but I haven’t added it yet, it works and I don’t get an error. somepackage exists in another environment, but I don’t want to use this - I want to dev somepackage to another folder somewhere in my new environment.
julia> using Pkg
Status `C:\Users\jodyd\.julia\environments\SpineOptDev\Project.toml` (empty project)
julia> using PyCall
You probably have PyCall installed in your default environment (the one which is active when you don’t explicitly activate any other, and is named after the current julia version, i.e. something like @vX.Y)
This default environment is normally stacked with the environment of the currently active project, so that any package missing from the currently active project can still be found in the default environment. Normally, you’d use this feature to put development tools (e.g. things like Revise, Debugger or ProfileView) in the default environment, so that you can use them when developing any project.
However, any package used in the code of you project should be explicitly Pkg.added as a dependency to it. And tools like Pkg.test should warn you if you forgot a dependency.
What I am actually trying to do here is maintain two branches of a repository simultaneously - a master branch and development branch. In my default environment I have the master branch dev’d. My idea is to create a new environment and in that, dev a duplicate of the package but with a different branch checked out. Will this work? In my new project, if I simply Pkg.dev(path\to\dev\repo) will this do what I want?
I think you need two copies of the repo to do that. The dev’d branch will be that active on each copy.
(but note that you can switch between branches quite easily, and if you use Revise, when you switch branches, the current branch will be the one being tracked. So maybe you don’t really need two environments).