Add repo outside of github as dependency to local package

Hi all,

I have a project that is set up as a local package using PkgTemplates. I would like to add a private Julia package that is hosted on a git repo outside of Github. I am having trouble getting it to work.

I added the package via the url (note this is not the real URL):

] add my_url.git

(I also tried without .git). After entering my name and password, everything seemed to download and update correctly. When I check the status I get the following:

  Status `~/.julia/dev/temp/Project.toml`

[31c24e10] Distributions v0.25.49
[144cker13] MyPackag v0.1.0 my_url.git#master

Project.toml and Manifest.toml look normal as far as I can tell. I see the package in .julia/packages. However, when activate my environment and enter using MyPackage, I receive an error indicating MyPackage is not installed. However, if I try using Distributions it loads (note distributions is not in my global environment, so it can only load from the project environment). Is there something I need to do to get it to work?

Thanks!

It sounds like it should work to me.

Can you provide any more specifik details, e.g. the error trace you get?

Thanks for your reply. Here is the trace:

julia> using MyPackage
ERROR: ArgumentError: Package MyPackage not found in current path:
- Run `import Pkg; Pkg.add("MyPackage")` to install the MyPackage package.

Stacktrace:
  [1] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:967
  [2] eval
    @ ./boot.jl:373 [inlined]
  [3] eval
    @ ./Base.jl:68 [inlined]
  [4] repleval(m::Module, code::Expr, #unused#::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:157
  [5] (::VSCodeServer.var"#71#73"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:123
  [6] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
  [7] with_logger
    @ ./logging.jl:623 [inlined]
  [8] (::VSCodeServer.var"#70#72"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:124
  [9] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [10] invokelatest(::Any)
    @ Base ./essentials.jl:714
 [11] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [12] (::VSCodeServer.var"#55#56")()
    @ VSCodeServer ./task.jl:423

Is this just a typo in manual scrubbing of actual URL/package name? Otherwise, this might indicate a typo in your project file (MyPackagMyPackage).

The most common explanations to this are

  1. You made a typo in the package name (capitalization, whatever).
  2. You are not running in the environment you think you are.
  3. You didn’t add the package to the environment you think you did.

You might have some other problem but do what you can to rule out all of the above first.

Sorry about that. Yeah. I scrubbed some of the info and introduced a typo. I double checked Project.toml and the correct package name is there along with the uuid under deps.

You may also want to try this from a plain REPL to rule out that VSCode is confounding matters.

I deleted Project.toml and Manifest.toml, repeated the setup, and now it is working. I have no idea what was causing the problem. I probably did something wrong, but I still have no clue :laughing:. At least it is working now. Thank you everyone for your help nonetheless.