Creating empty isolated environment

I try to create a clean Pkg environment, completely independent from my “normal” default one with packages, and cannot get it right:

➜  mkdir tmp
➜  cd tmp
➜  julia --startup-file=no
(v1.1) pkg> activate .

(tmp) pkg> status
    Status `~/julia/tmp/Project.toml`
  (empty environment)

julia> using <TAB>
AverageShiftedHistograms DifferentialEquations     ImageFiltering            Logging                   Pkg                       Revise                    SuiteSparse
AxisArrays               Distributed               Interact                  LsqFit                    Plots                     SHA                       TensorCast
Base                     Distributions             InteractiveUtils          MLStyle                   Polychord                 Serialization             Test
Base64                   FFTW                      Interpolations            MacroTools                PooledArrays              Setfield                  TimerOutputs
BenchmarkTools           FINUFFT                   IterTools                 Markdown                  Printf                    SharedArrays              Traceur
CRC32c                   FITSIO                    JLD2                      Match                     Profile                   ShiftedArrays             Turing
CSV                      FTPClient                 JuMP                      Measurements              ProfileView               Sockets                   UUIDs
Conda                    FastTransforms            JuliennedArrays           Mmap                      ProgressMeter             SparseArrays              UnalignedVectors
Core                     FieldMetadata             Keys                      NFFT                      PyCall                    SpecialFunctions          Unicode
DataFrames               FileIO                    LaTeXStrings              NLopt                     PyPlot                    SplitApplyCombine         UnicodePlots
DataStreams              FileWatching              LibGit2                   NaNMath                   Query                     StatPlots                 Unitful
DataStructures           Flatten                   LibPQ                     NamedTupleTools           QueryOperators            StatProfilerHTML          UnitfulAngles
DataValues               Future                    Libdl                     Pandas                    REPL                      StaticArrays              UnitfulAstro
Dates                    Glob                      LinearAlgebra             Parameters                Random                    Statistics                VegaLite
DelimitedFiles           IJulia                    LocalFilters              PhysicalConstants         ResumableFunctions        StatsBase                 WebIO

As you see, status shows that there are indeed no packages installed in this new empty environment, however I still can import packages installed in my default environment with using, and they work. Shouldn’t I get a clear environment in this case by design?


I think you need to set the LOAD_PATH. See also How to install packages which are needed only for development


Yes. Assuming you have the default LOAD_PATH in the example above you have the following stack:

@,               # for active project
@v#.#,           # global environment for the current julia version
@stdlib          # Julias standard library

What you want in this example is probably just

@,               # for active project

which you can achieve by modifying load path, e.g.


Thank you, this works! I guess Pkg docs was the wrong place for me to look for this particular thing.
And how do I set LOAD_PATH without env variables, that is from inside julia? Do I really have to delete elements which are not “@” one by one, as it seems impossible to assign the whole array?

It would be good to document those things in the Pkg manual too. Do you want to contribute with that?

You can do e.g. this:

push!(LOAD_PATH, "@")