How to actively develop a package I am working on?


I have a package I am working on and currently my workflow is a bit of a hassle. I want to develop my package a bit more interactively, but currently my workflow is:

  1. Do changes
  2. Commit changes to Github and push
  3. Remove previous install of package
  4. Reinstall package
  5. Run and test code

Which is quite of a hassle and does not feel to interactive. I am sure I have missed something basic, would anyone kindly give me a step in the right direction?

Kind regards, Ahmed

Okay, I think I figured it out!

What worked for me:

  1. Install packages for general use in global namespace, such as Revise, BenchmarkTools etc.
  2. In your run script (NOT module!) put using Revise
  3. Restart Julia
  4. Now, if you are in the project folder and have activated environment, by ] activate . or similar, then when you do changes in a submodule of your using MyPackage, these are propagated through the using Revise and you do not have to restart Julia terminal.

You need to make sure the project name matches using MyPackage I think, not sure.

Now I don’t have to do that really annoying workflow above :slight_smile:

Kind regards

Note that there is a Revise.includet that allows you to reload a file when it changes. The final t is not a typo. This is usually useful when you are trying to develop code outside of the context of a package. Otherwise, it seems like you mostly figured it out.

1 Like

Yes, thanks for including that :slight_smile:

It is because I am working on my package and in the test script I do; using MyPackage - then now because I have using Revise at the top of the test script, when I do changes inside of MyPackage in the local code it propagates correctly and I do not need to restart Julia.

Wish I had understood earlier that Revise also works with packages, hopefully it helps someone in the future :sweat_smile:

Kind regards

This will work, but personally I don’t like the idea of putting using Revise in your run script (ideally your run script should only be using packages that are in its Project.toml). I would recommend doing one of the following:

  1. Simply write using Revise in the REPL before the first time that you include your run script in every new Julia session
  2. Add the line using Revise to your ~/.julia/config/startup.jl file
  3. Do like me, add the following line to your ~/.bashrc or similar:
alias j='julia -i -e "using Revise"'

which will start Julia with Revise preloaded when you use the command j on the command line. If you use Windows, then I think that you would need to write a .bat script to achieve something like this.

Finally, I just want to make sure that you are aware of Julias built in Unit test framework which would normally be a good supplement or replacement for your run script.



I might have to look into this, since my workflow seems to have broken again…

The unit test framework looks great for testing out smaller components of functionality, thanks! Currently I am just developing and it is nice to do so through a script for me.

Kind regards, thanks for the help

1 Like

For more workflow tips, you can check out this (still incomplete) series of blog posts