How do I edit and test code changes in a package

I’m new to Julia and inherited a package from a work member (the only one with Julia experience around, left the company)
I know how to install the package from my git repo, but I have no clue how to make my local changes available in the Julia notebook I’m using. Is there a tutorial how and what to do during the package development itself, before pushing the code changes to the git repo again?

Take a look at this section from the manual: Workflow Tips · The Julia Language

I’m sure there’s good tutorials around but basically what you want to do is:

  1. In package mode, dev the package ]dev https://github.com/user/MyPackage.jl
  2. Add Revise to your default environment
  3. In your notebook (jupyter I assume?) activate a local or temporary environment (]activate . or ]activate --temp) and dev MyPackage
  4. Then do using Revise, MyPackage to load the development version of your package and have changes tracked by Revise

Now you can edit the source code of MyPackage, which will be stored in .../.julia/dev/MyPackage in your favourite editor and when saving the source code, changes will be reflected live in your notebook.

8 Likes

Could you please elaborate on why it is necessary to dev the package twice?

The first dev is to download the package to your local dev folder, the second is to make sure you are actually using the dev version of the package (whereas add would try to add the release version from a registry).

This is a bit made up tbh, I can’t point you to official docs on this!

I’m thinking that only the second one is actually necessary, but using the full package URL as in your first call.

That’s probably right, I guess it doesn’t matter where you do the dev call as that will always look in the dev folder irrespective of environment.

I just modified an example in the Revise.jl documentation that includes a very specific demonstration.

In the example, I used write where you might use an editor to modify your package.

3 Likes