Julia 0.7/1.0 workflow

Hello,

What is the preferred/recommended workflow for developing/maintaining packages, in terms of interaction between developing code in an editor, julia-0.7, and testing the package.

I am used to having a package Mymodule I am working on somewhere in .../work/julia/Mymodule.jl

Before julia-0.7, the lines

include("src/Mymodule")
using Mymodule

would make sure I was using the most recently edited code. But with 0.7, and the new package manager, an older version of the package stored somewhere under ~/.julia always gets the precedence over my current working directory.

Even when I try to add the package using

pkg> add ../Mymodule.jl
pkg> update
using Mymodule

I still seem to be exposed to the old version, but this is probably because I don’t understand the new package manager.

Is there a way I can have quick access to the newly edited code without checking code in and adding to the package manager?

Thanks,

—david

This is a job for pkg> develop. develop (or dev in short) will track a local path. For example, I have the Example package locally in ~/dev/Example, so I can dev the path:

(v1) pkg> dev ~/dev/Example
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [7876af07] + Example v0.5.1+ [`~/dev/Example`]

Note that in the status output we see a path ([~/dev/Example]) which we are now tracking, meaning that changes you do to the code there will be picked up.

pkg> add in contrast, takes a snapshot of the git repository from the path, and stores that internally in .julia/packages/.... The difference is that this code will not change when you change the code where you originally had the package (unless you commit and update etc). Cf the output when adding a path:

(v1) pkg> add ~/dev/Example
  Updating git-repo `/home/fredrik/dev/Example`
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [7876af07] + Example v0.5.1+ #master (/home/fredrik/dev/Example)

Here we can see see that we are tracking the branch #master and the repo “url” (in this case a local path) is (/home/fredrik/dev/Example).

3 Likes

Thanks, this works for me indeed.

For my own reference, because I spent another hour or so figuring this out again, until I stumbled upon my own question (I seem to be pretty stubborn, forgetful and stupid):

pkg> dev ../Mymodule.jl
julia> using Mymodule

a process that does not seem to be documented (at least clearly enough for me) in either Pkg · The Julia Language or My New Workflow with Julia 1.0. A practical guide to how you can work… | by Erik Engheim | Medium

If you feel like the docs could be improved, please make a PR! The people using the language most extensively often don’t/can’t see where it could be improved, since they’re already very familiar with how it all works. Since you’ve experienced the problem first hand, you’re also the most knowledgable about what is missing :slight_smile:

3 Likes

I am sorry. I would love to submit a PR for documentation, but then I would need to understand things first. For some reason that is too hard for me. I am still regularly lost in the julia-1.0 package loading system, so that I keep switching back to julia-0.6, where for some reason it is easier for me to figure out what is going on.