I use Julia0.6 and I can't install any package and neither use Pkg.status().
```
julia> Pkg.status()
ERROR: GitError(Code:ENOTFOUND, Class:Reference, Revspec 'HEAD' not found.)
Stacktrace:
[1] macro expansion at .\libgit2\error.jl:99 [inlined]
[2] Base.LibGit2.GitTree(::Base.LibGit2.GitRepo, ::String) at .\libgit2\repository.jl:116
[3] #isdiff#76(::Bool, ::Function, ::Base.LibGit2.GitRepo, ::String, ::String) at .\libgit2\libgit2.jl:147
[4] (::Base.LibGit2.#kw##isdiff)(::Array{Any,1}, ::Base.LibGit2.#isdiff, ::Base.LibGit2.GitRepo, ::String, ::String) at .\
[5] isfixed(::String, ::Base.LibGit2.GitRepo, ::Dict{VersionNumber,Base.Pkg.Types.Available}) at .\pkg\read.jl:64
[6] #7 at .\pkg\read.jl:213 [inlined]
[7] with(::Base.Pkg.Read.##7#8{Dict{String,Tuple{VersionNumber,Bool}}}, ::Base.LibGit2.GitRepo) at .\libgit2\types.jl:608
[8] installed(::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}) at .\pkg\read.jl:211
[9] #status#9(::String, ::Function, ::Base.TTY) at .\pkg\entry.jl:130
[10] (::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#status,Tuple{Base.TTY}})() at .\pkg\dir.jl:36
[11] cd(::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#status,Tuple{Base.TTY}}, ::String) at .\file.jl:59
[12] #cd#1(::Array{Any,1}, ::Function, ::Function, ::Base.TTY, ::Vararg{Base.TTY,N} where N) at .\pkg\dir.jl:36
[13] status(::Base.TTY) at .\pkg\pkg.jl:154 (repeats 2 times)
julia> versioninfo()
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
```
From the outside this looks like a problem of your local copy of the METADATA directory (or julia home).
@lobingera how i can fix this?
First of all you should be sure it's the actual error. To me it looks like, if Pkg.status is complaining about a missing HEAD then it's mostlikely METADATA. Do you have git as commandline or GUI tool available? Then go into the METADATA directory and run git status.
The classical way to build a fresh and new julia home is:
thanks for your solution, it worked!, but I am seriously worried that it will happen again, I.ve lost a lot of time with this and i'm not sure if everything is ok, the size of the home dir had more than 2GB, that after removal it, the Pkg.update function it took longer than desired. How can i avoid this error?, I do not know what I did to make it happen. according to https://github.com/JuliaLang/julia/issues/17994 I should not use Pkg.free in some cases, perhaps in no case until the problem is fixed.
Hi.
I just had this sort of error on Ubuntu (bionic) box and Julia 0.6.2.
The solution of @lobingera worked for me, but it's quite time consuming. Shouldn't this issue have been solved already?
This doesn't happen in the normal course of using Julia, so it seems likely that something weird happened on your system. Did you muck about in the METADATA directory? Or run out of disk space?
For me while I was trying to add a Pkg my internet got disconnected and now am getting the same error! Any way out?
Delete ~/.julia/registries/General
and try again.
To be clear, this is not the same error as in 2018 (there's an entirely different package manager), you just happen to be seeing the same error message from LibGit2.
Most helpful comment
First of all you should be sure it's the actual error. To me it looks like, if Pkg.status is complaining about a missing HEAD then it's mostlikely METADATA. Do you have git as commandline or GUI tool available? Then go into the METADATA directory and run git status.
The classical way to build a fresh and new julia home is: