[SOLVED] Unable to use local package

I’ve got a local copy of a package that I’ve modified to work with Julia 1.0 and would like to send it to someone else. One option is to have them download the original package, make the edits in place, and then use the modified package, but that seems like a lot of unnecessary work.

I’d like to send the package and have the other person install the local copy, but I can’t find a way to do this. It looks like every package has to be a git repository (which makes no sense to me, seems like an unnecessary restriction for local packages if they don’t require updates), but even when I’ve initialized the package files as a git repository (cd into package directory and git init) I get an error:

ERROR: GitError(Code:EUNBORNBRANCH, Class:Reference, reference 'refs/heads/master' not found)
Stacktrace:
 [1] head(::LibGit2.GitRepo) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/LibGit2/src/error.jl:101
 [2] branch(::LibGit2.GitRepo) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/LibGit2/src/LibGit2.jl:368
 [3] #handle_repos_add!#32(::Bool, ::Nothing, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:638
 [4] #handle_repos_add! at ./none:0 [inlined]
 [5] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:54
 [6] (::getfield(Pkg.API, Symbol("#kw##add_or_develop")))(::NamedTuple{(:mode,),Tuple{Symbol}}, ::typeof(Pkg.API.add_or_develop), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at ./none:0
 [7] do_add!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:709
 [8] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:697
 [9] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:696
 [10] do_cmd!(::Pkg.REPLMode.PkgCommand, ::REPL.LineEditREPL) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:603
 [11] #do_cmd#33(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:577
 [12] do_cmd at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:573 [inlined]
 [13] (::getfield(Pkg.REPLMode, Symbol("##44#47")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:912
 [14] #invokelatest#1 at ./essentials.jl:697 [inlined]
 [15] invokelatest at ./essentials.jl:696 [inlined]
 [16] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2261
 [17] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:1029
 [18] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:191
 [19] (::getfield(Base, Symbol("##719#721")){Bool,Bool,Bool,Bool})(::Module) at ./logging.jl:311
 [20] #invokelatest#1 at ./essentials.jl:697 [inlined]
 [21] invokelatest at ./essentials.jl:696 [inlined]
 [22] macro expansion at ./logging.jl:308 [inlined]
 [23] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:330
 [24] exec_options(::Base.JLOptions) at ./client.jl:242
 [25] _start() at ./client.jl:421

What else do I have to do to get this package to install?

1 Like

Use dev if you want to add a package by the path.

The error after git init is because there isnt a commit in it.

I’ve tried that and, while it seems to add the package successfully, when I try running a script that depends on that package, it says the package is required but does not seem to be installed and suggests running Pkg.instantiate() to install all recorded dependencies. Doing so doesn’t install anything.

And the package have the correct “structure” e.g. there is a src/Package.jl file with a module Package in it?

Thanks, that was the problem. I forgot to remove the intermediate folder created by Julia. I just copied the package straight from the .julia/packages directory, but forgot the contents of the package got put inside another directory within the directory with the package name. After moving the files from within the second directory up to the main package directory, adding the package with dev works just fine.

Julia seems to cache this information somewhere.
I accidentally tried to dev a library before sending the first commit to GitHub, and now I cannot dev it at all from that computer (but I can from others).

Which file do I have to delete?

EDIT:
I fixed the problem via (not sure which one did it, but I didn’t want to spend any more time than necessary):

> rm -rf dev
> rm -rf packages
> rm -rf registries
> rm -rf environments
> rm -rf compiled
> rm -rf clones

Now it works.

I ran into this issue today and had to remove the package from the clones folder. I believe Julia is making a clone of the repo and using that for any future adds. The clones directory will possibly have many different directories in it and it won’t be obvious which one needs to be removed. I had to search for the string of the name of local package which was found in the config file. I then knew which directory to delete.

1 Like

You can find the particular dir to remove with e.g. ripgrep:

rg PACKAGENAME ~/.julia/clones/*/config

You should get a match in a file with a name like .julia/clones/10050710805520036482/config. rm -rf it’s parent directory.

3 Likes