Loading a package from a fork

Apologies but I can’t seem to find clear documentation on this.
[and the little I did find didn’t work]

I have created a fork from a package on github, and before tinkering with it, I want to see how to just load the package (as is) from the fork (as a test).

Most of the documentation I found seems to refer to Pkg.clone(), but I saw elsewhere that this seems to be deprecated and subsumed into Pkg.add().
(First question) Is this correct?

Assuming the answer to the above is ‘yes’, I tried to add Pkg.add() with my forked url path on github but it didn’t work.

(Second question) Do I need to do something first to my forked package on github after having created it using ‘fork’ in order to be able to load it with ‘add’?

(third question) There was reference somewhere to using the ‘#’ to refer to a forked version of a package. How does this work?

Sorry for such basic questions, but thanks for any help.

Try doing:

add <url>

The ]' goes into the package manager and add ` adds the package. Granted Pkg.add() should be doing the same thing I believe. So my question would be how did Pkg.add() fail?

1 Like

If you want to add a package from a url using the Pkg api (rather than the package manager repl mode as @pixel27 suggested) you need to do


That will work with a git ssh repo addresses. The Pkg.add(pkg_name::String) method only works for registered packages that you can refer to by name, i.e. Pkg.add("DataFrames").

FWIW, if you’re planning to play with a fork of a package, I would just do

Pkg.develop(url="address of your fork repo")

That will clone your fork of the package into your julia package development directory. If you then import the package (i.e. using ForkedPackage) it will load the version you’ve just cloned. If you want to go back to a registered version of the package just do Pkg.free("ForkedPackage") or run

free ForkedPackage

from the package manager repl mode. Then the next time you want to switch back to your local version of the package just do

dev ForkedPackage

and the package manager will switch back to the version of the package sitting in your package development directory.

Finally, by default your julia package development directory is ~/.julia/dev but you can set it to be somewhere else using the environment variable JULIA_PKG_DEVDIR. For more info see the developing package section of the package manager docs: https://julialang.github.io/Pkg.jl/v1/managing-packages/#developing

1 Like

Developing an existing package is explained here:

The julia package manager docs (your third question) is here:

The ‘#’ symbol is used more to check out a specific branch. I think this can include other people’s PR (pull request) branches, but that’s different than you creating a PR branch (which your post above seems to be about)

Thanks so much all!

Some of the above I had tried and had not worked, but I will try your other suggestions first before trying to troubleshoot the ones that didn’t work.
If I do need to troubleshoot latter, I will post the error(s) I got.
Thanks again.

*** I tried again and the error I keep getting is ‘cross-host redirect not allowed’

Whenever I tri the suggestions above, I get the error

ERROR: failed to clone from https://www.github.com/compleathorseplayer/Pluto.jl, error: GitError(Code:ERROR, Class:Net, cross host redirect not allowed)

Try “https://github.com/compleathorseplayer/Pluto.jl” without the www.

Thank you! That worked!

[I did get some unsatisfiable requirements, which is a different issue (fixed)]

Just one last thing (nearly there!)

What if the version I want is actually …/<Pkg name>.jl/tree/<branch name>

Should I have forked the whole Package and refer to the branch on import,
or should I just fork the branch and it will be assumed when I import?
Thanks again!



Some of the examples it shows:

  Pkg.add("Example") # Add a package from registry
  Pkg.add("Example"; preserve=Pkg.PRESERVE_ALL) # Add the `Example` package and preserve existing dependencies
  Pkg.add(name="Example", version="0.3") # Specify version; latest release in the 0.3 series
  Pkg.add(name="Example", version="0.3.1") # Specify version; exact release
  Pkg.add(url="https://github.com/JuliaLang/Example.jl", rev="master") # From url to remote gitrepo
  Pkg.add(url="/remote/mycompany/juliapackages/OurPackage") # From path to local gitrepo
  Pkg.add(url="https://github.com/Company/MonoRepo", subdir="juliapkgs/Package.jl)") # With subdir

Yes, that helped immensely. It is all working now.

Thank you so much!