Adding a package from local directory gives strange results

I’m trying to transition a web-server project I wrote to a package so that I can use packagecompiler.jl to precompile it and reduce startup latency. I would like to test the package precompiliation locally in a docker container. However, I’m getting stuck at adding the package.

If I do

pkgPath = joinpath(@__DIR__, "CCG_Server")
union!(LOAD_PATH, [pkgPath])
using CCG_Server

Everything works as expected (although it takes a while to precompile) and it displays the local constant SERVER_ENV. However, if I rebuild the docker container and do

import Pkg
import Pkg.PackageSpec
pkgPath = joinpath(@__DIR__, "CCG_Server")
using CCG_Server

The package loading is suspiciously fast and when all is done, it says that “UndefVarError: SERVER_ENV not defined”. In fact NONE of the functions in CCG_Server exist. It seems like it’s only a recursive field

1-element Vector{Symbol}:

What happened? I have the Project.toml file set up with the deps and everything. Is there something I’m missing?

Pkg.add of a local path is rarely something you want. It makes a snapshot of what has been committed to the git repository at the local path and uses that as your package. You probably want to use whatever code is currently visible at the path and then it’s Pkg.develop of the local path you should use.


That was the missing piece, everything else came together perfectly! THANK YOU! I admit that was something I was going to try and should have tried earlier; I just doubted that Pkg.develop would be compatible with packagecompiler.jl, but it turns out that they are COMPLETELY compatible. This will save a LOT of startup time for my server application.