Installing from a subdirectory of Github

I have a Julia package on GitHub for which I’d like to include installation instructions. However, the Julia code is in a subdirectory of the repo as this repo includes both a Julia and R version of the code.

I can’t figure out how remotely install the package from the subdirectory. My first pass was


This leads to a 404 error. Is there a way to specify a subdirectory of a repo?

EDIT: I have split up the R and Julia repos so the link above currently is broken.

I don’t have a solution for your problem, but as a workaround, you could git clone the repository (in the shell) and then in Julia pkg> add or pkg> dev the relevant path.

1 Like

Go here and read using someone elses project:’s-project-1
download and clone the project.
In Julia then:

]activate .

Also try this it may work:

You can include a package name as the second argument.


Thanks for the suggestions.

I think best practices is going to be split up the repo into an R and Julia implementation. I think it’s a bit sub-optimal to have a user clone a bunch of code they don’t want (i.e. R version) and then muck around with a subdirectory of the repo, rather than just call Pkg.add("blahblah").

Now, the

using Pkg
Pkg.add(PackageSpec(url="", subdir="Julia/LatentChannelNetworks"))

should be working, since add subdir functionality by KristofferC · Pull Request #1422 · JuliaLang/Pkg.jl · GitHub
but I haven’t tried it for nested subdirectories. It works on single subdir without further nesting, for me.
The monorepo/subdirectory should be fully supported by the Pkg.jl and the whole package registry by now.

1 Like

You can also use the following syntax in the REPL:

pkg> add

This is now listed in the ?Pkg.add examples:

help?> Pkg.add
  Pkg.add(pkg::Union{String, Vector{String}}; preserve=PRESERVE_TIERED)
  Pkg.add(pkg::Union{PackageSpec, Vector{PackageSpec}}; preserve=PRESERVE_TIERED)
Pkg.add(url="", subdir="juliapkgs/Package.jl)") # With subdir

The keywords are forwarded to PackageSpec.