Coming from a Python background, I am now trying to learn Julia, so my problem may be related to my confusion between virtual environments between Python and Julia. In Julia, I experience difficulties adding packages into a project virtual environment. BUT I have no problems adding packages when I am not using a project environment, such as within REPL:
(@v1.6) pkg>add CSV
successfully adds the CSV package. However, when I activate my project environment (called self_learn
) and try to add this same package into this environment, I see these error messages within REPL:
(@1.6) pkg> activate .
(self_learn) pkg> st
Project self_learn v0.1.0
Status `D:\Dropbox\Julia\self_learn\Project.toml` (empty project)
(self_learn) pkg> add CSV
Resolving package versions...
Updating `D:\Dropbox\Julia\self_learn\Project.toml`
[336ed68f] + CSV v0.8.4
Updating `D:\Dropbox\Julia\self_learn\Manifest.toml`
[336ed68f] + CSV v0.8.4
[9a962f9c] + DataAPI v1.6.0
[e2d170a0] + DataValueInterfaces v1.0.0
[82899510] + IteratorInterfaceExtensions v1.0.0
[69de0a69] + Parsers v1.1.0
[2dfb63ee] + PooledArrays v1.2.1
[91c51154] + SentinelArrays v1.2.16
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.4.2
[2a0f44e3] + Base64
[ade2ca70] + Dates
[9fa8497b] + Future
[b77e0a4c] + InteractiveUtils
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[56ddb016] + Logging
[d6f4376e] + Markdown
[a63ad114] + Mmap
[de0858da] + Printf
[9a3f8284] + Random
[9e88b42a] + Serialization
[8dfed614] + Test
[4ec0a83e] + Unicode
Precompiling project...
Progress [> ] 0/1
◑ self_learn
┌ Error: Pkg.precompile error
│ exception =
│ ArgumentError: Invalid header in cache file C:\Users\Admin\.julia\compiled\v1.6\self_learn\jl_A3B4.tmp.
│ Stacktrace:
│ [1] preferences_hash(cachefile::String)
│ @ Base .\loading.jl:1478
│ [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOBuffer, internal_stdout::Base.DevNull)
│ @ Base .\loading.jl:1337
│ [3] (::Pkg.API.var"#215#242"{IOBuffer, String, Base.PkgId})()
│ @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:1144
│ [4] with_logstate(f::Function, logstate::Any)
│ @ Base.CoreLogging .\logging.jl:491
│ [5] with_logger
│ @ .\logging.jl:603 [inlined]
│ [6] macro expansion
│ @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:1143 [inlined]
│ [7] (::Pkg.API.var"#212#239"{Bool, Vector{Task}, Pkg.API.var"#handle_interrupt#231"{Base.Event, ReentrantLock, Base.TTY}, Pkg.API.var"#color_string#229", Base.Event, Base.Event, ReentrantLock, Vector{Base.PkgId}, Vector{Base.PkgId}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Vector{Base.PkgId}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, Base.Event}, Dict{Base.PkgId, Bool}, Dict{Base.UUID, Pkg.Types.PackageEntry}, Vector{Base.PkgId}, Bool, Base.TTY, Base.Semaphore, String, Vector{String}, Vector{Base.PkgId}, Base.PkgId})()
◐ self_learn
(self_learn) pkg>
Adding other packages such as DataFrames
and Pipe
result in the same precompile errors. I have tried uninstalling and reinstalling Julia 1.6.1, but this issue persists. I am using Windows 10.
Any help will be appreciated.
Pkg is Julia’s built-in package manager and handles operations such as adding, updating and removing packages. Pkg has it’s own read — evaluate — print — loop (REPL). In my workflow, when I want to create a new project environment, I usually start Julia from the directory where I keep my coding projects.
To update all installed packages, use update without any arguments: Up to this point, we have covered basic package management: adding, updating and removing packages. This will be familiar if you have used other package managers. Pkg offers significant advantages over traditional package managers by organizing dependencies into environments.
This new environment is completely separate from the one we used earlier. The REPL command precompile can be used to precompile all the dependencies in the project. You can for example do to update the dependencies and then precompile them. Simply clone their project using e.g. git clone, cd to the project directory and call (v1.0) pkg> activate .
An introduction to Julia’s built-in package manager for generating project environments and managing package dependencies. W hen you start to code multiple projects in Julia, it is recommended to use project specific environments for reproducibility and minimizing package dependencies. Julia has a great built-in package manager to make things easy.
The package cache for your module seems to be stalled.
This hast most likely happened when you were installing packages for your module and hit Ctrl+Enter
- the package repo usually does not survive situations too well.
Uninstalling Julia did not help because the package repo is held in a ~/.julia
(or %HOME%\.julia
on Windows) folder that lives independently of Julia installation.
What you need to do is just to delete the folder: C:\Users\Admin\.julia\compiled\v1.6\self_learn\
If this does not help you might need to install the entire C:\Users\Admin\
but this would require re-installation of all packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With