Manging Local Package & Workflow

Hello,

I have a package I am developing locally. I created the package using ] generate and have added it to a local registry so that I may share it easily with collaborators. Both the package and the local registry have their own git repos.

Separately, I have a development environment that I use (created via ] activate MyEnvironment). I added my local registry to the environment and then added my package via ] add MyPackage.

Now I want to be able to run code like this in a script file (starting in my specific environment is already taken care of via julia.environmentPath in VsCode)

using MyPackage, Revise

testing = MyType(...)
testresult = MyFunction(testing)

while at the same time making changes to my package, so I can see the impact in real time (via Revise). But it does not appear to be working. For example I defined a new function in MyPackage and added it to the export list and I get an error that the new function is not defined. But if I do instead

include("Path/To/MyPackage.jl")
using .MyPackage, Revise

testing = MyType(...)
testresult = MyFunction(testing)
testresult2 = MyNewFunction(testing) # newly exported function

Well now each time I restart the script the change is reflected but Revise does not appear to track changes anymore.

Am I going about this the wrong way? I’m sure there is a better way and would appreciate any advice.

You probably want to develop your packade instead of adding it, so dev local/path/MyPackage instead of add MyPackage. This makes i look at this path instead of a specific git commit.
And i think you also need to run using Revise before any other using for it to work with the other package, though maybe vscode is doing something in the background here.

perhaps replacing

include("Path/To/MyPackage.jl")

with the Revise version

includet("Path/To/MyPackage.jl")

will cure your problem

You’re loading Revise after you load the package. That won’t work. (see “importantly…”)

If there’s a place this info would have been easier to find, I’m open to suggestions.

Thank you both for the quick responses. No - I think that is well placed (the link) I was just being oblivious. I ended up fixing it by activating my environment, using Pkg remove MyPackage and then re-adding locally (instead of via the registry) by doing julia> Pkg.develop(path="PATH/TO/MYPACKAGE/"). Also realized the using Revise is unnecessary in my script example above because I have it setup to load automatically with the environment (via startup.jl).

1 Like