What is the appropriate way to clone packages in dockerfile?

I am trying to clone or add a package from my repo in dockerfile, I am using:

RUN julia -e 'import Pkg; Pkg.clone("https://github.com/jingpengw/GoogleCloud.jl.git")'

but I was told that I should use add rather than clone

ā”Œ Warning: Pkg.clone is only kept for legacy CI script reasons, please use `add`
ā”” @ Pkg.API /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:445

after I replace the clone with add, I got errors. I am probably not using it correctly. The terminal hint is not quite explicit.

1 Like

Well, what errors are you getting?

julia> Pkg.add("https://github.com/jingpengw/GoogleCloud.jl.git")'
WARNING: Base.Pkg is deprecated, run `using Pkg` instead
 in module Main
ERROR: https://github.com/jingpengw/GoogleCloud.jl.git is not a valid packagename
Stacktrace:
 [1] pkgerror(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:120
 [2] check_package_name(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:22
 [3] iterate at ./generator.jl:47 [inlined]
 [4] collect(::Base.Generator{Array{String,1},typeof(Pkg.API.check_package_name)}) at ./array.jl:619
 [5] #add_or_develop#11(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:mode,),Tuple{Symbol}}}, ::Function, ::Array{String,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:28
 [6] #add_or_develop at ./none:0 [inlined]
 [7] #add_or_develop#10 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:27 [inlined]
 [8] #add_or_develop at ./none:0 [inlined]
 [9] #add#18 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:69 [inlined]
 [10] add(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:69
 [11] top-level scope at none:0

using Pkg
Pkg.add(PackageSpec(url="https://github.com/jingpengw/GoogleCloud.jl.git"))

(see the docs)

3 Likes

can you post an example using ssh instead of https?

I am using the following in Gitlab CI:

julia -e "using Pkg; Pkg.add(\"git@gitlab.com:MyPackages/MyPkg.jl.git\")"

but I keep getting this error:

ERROR: git@gitlab.com:MyPackages/MyPkg.jl.git is not a valid packagename

using Pkg
Pkg.add(PackageSpec(url="git@gitlab.com:MyPackages/MyPkg.jl.git"))

(see the docs)

2 Likes

Ok. Just wanted to confirm. In the docs there is no example with the git@... format, maybe it could be added.

That would be a nice addition