How to reload local package?

Hello.

I did something and I am not sure how to fix it.

I started working on a project/package and build a module. I think I activated the package and now the following happened. If I go to the REPL adding my package loads an older version of it. How do I change that.

Thank you in advance!

You may find Revise.jl to be helpful! It automatically reloads code when it is edited.

1 Like

Yes I use that. But this was a larger project and I am unsure what went wrong. In the reply I can using myPackage but is an old version and I am trying to change that.

It sounds like you might have done Pkg.add of your local package when you should have done Pkg.develop. The former makes a snapshot of the package whereas the latter uses what is currently there.

1 Like

Thank you! How do I correct that?

Do a Pkg.develop of your package. If that doesn’t work you’ll need to provide a more precise description of your setup.

I cannot thank you enough. I tought I was going crazy.

Take a look at this blog post to learn more about environments. Use Pkg.status to check the installed packages in your current environment, and make sure to remove the version you Pkg.added before doing Pkg.develop on it.

An added version will show a git branch name at the end:

(@Code2021) pkg> st
Status `C:\Users\nboyer\.julia\environments\Code2021\Project.toml`
  [41458dd0] KD232 v0.1.0 `\\Path\to\package\KD232#master`
  [0ccbab1c] KM620 v0.1.0 `\\Path\to\package\KM620#master`

A deved version will show just the path:

(@Code2021Dev) pkg> status
Status `C:\Users\nboyer\.julia\environments\Code2021Dev\Project.toml`
  [41458dd0] KD232 v0.1.0 `\\Path\to\package\KD232`
  [0ccbab1c] KM620 v0.1.0 `\\Path\to\package\KM620`

Why? As far as I know Pkg.develop will simply replace what you previously Pkg.added.

1 Like

yes. I tried only develop and it worked. So I assume it got replaced.

1 Like