# Pkg: REPL \<-\> API equivalence

**URL:** <https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177>\
**Category:** General Usage\
**Tags:** pkg\
**Created:** [November 27, 2024, 3:30pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177 "2024-11-27T15:30:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [November 27, 2024, 3:30pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177/1 "2024-11-27T15:30:53Z")

</div>

In order to automate the instantiation of projects in non-standard/complex cases, I sometimes write small `setup.jl` scripts relying on `Pkg`’s programmatic API.

This is very nice, but I occasionally struggle finding the API equivalent for a given `pkg>` REPL command. I know about the equivalence table given in the [`PackageSpec`](https://pkgdocs.julialang.org/v1/api/#Pkg.PackageSpec) docstring but, although it’s very useful in a lot of cases, it isn’t comprehensive and does not cover some corner cases (which is perfectly understandable for a docstring).  
Apart from that, is there a way to find out the API call equivalent to a given REPL command?

If there is no general way to do that, would someone know the equivalent for the following REPL command?

```julia-repl
pkg> dev --local SomePackage

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 27, 2024, 3:34pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177/2 "2024-11-27T15:34:26Z")

</div>

I think you can use, always,

```julia
pkg"dev --local SomePackage"

```

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [November 27, 2024, 3:39pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177/3 "2024-11-27T15:39:56Z")

</div>

Thanks. Yes, I know and this is what I end up using when I don’t know how to do better.

However, I’m always reluctant to use this because of the warnings it produces:

```shell
shell$ cat >setup.jl <<EOF
> using Pkg
> pkg"activate ."
> EOF

shell$ julia setup.jl 
┌ Warning: The Pkg REPL mode is intended for interactive use only, and should not be used from scripts. It is recommended to use the functional API instead.
└ @ Pkg.REPLMode ~/.julia/juliaup/julia-1.10.7+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/REPLMode/REPLMode.jl:382
  Activating new project at `/tmp`

```

I read that warning message as an indication that equivalent API exists for each REPL command and should be preferred in scripts. But maybe I’m wrong? Or maybe I shouldn’t care too much?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [November 27, 2024, 4:34pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177/4 "2024-11-27T16:34:00Z")

</div>

Given that

```julia
julia> methods(Pkg.develop)
# 7 methods for generic function "develop" from Pkg.API:
 [1] develop(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; shared, preserve, platform, kwargs...)

```

shows a keyword argument `shared`, I would try setting that to `false`.

I believe that the main reason for the warning about using `pkg`-strings is that in the general case they involve various parsing heuristics, to e.g. guess if something is a URL, which might change without notice between versions.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [November 27, 2024, 4:42pm UTC](https://discourse.julialang.org/t/pkg-repl-api-equivalence/123177/5 "2024-11-27T16:42:15Z")

</div>

Thanks, that answers the specific question about `dev --local`:

```julia-repl
julia> using Pkg

julia> Pkg.develop("Example", shared=false)
     Cloning git-repo `https://github.com/JuliaLang/Example.jl.git`
   Resolving package versions...
    Updating `/tmp/Foo/Project.toml`
  [7876af07] ~ Example v0.5.5 ⇒ v0.5.5 `dev/Example`
    Updating `/tmp/Foo/Manifest.toml`
  [7876af07] ~ Example v0.5.5 ⇒ v0.5.5 `dev/Example`

```
