# Pkg.add with a URL

**URL:** <https://discourse.julialang.org/t/pkg-add-with-a-url/29475>\
**Category:** General Usage\
**Created:** [October 4, 2019, 7:44am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475 "2019-10-04T07:44:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 4, 2019, 7:44am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/1 "2019-10-04T07:44:24Z")

</div>

Is there some reason why we have to do

```julia
Pkg.add(PackageSpec(url="https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl"))

```

instead of

```julia
Pkg.add("https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl")

```

? Couldn’t this conversion happen inside `add`?

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [October 4, 2019, 7:50am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/2 "2019-10-04T07:50:14Z")

</div>

`PackageSpec` allows encapsulating more information i.e. branches, commits etc. I believe a method for just the link is too little and programatically is not a big deal adding the wrapper around.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 4, 2019, 8:02am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/3 "2019-10-04T08:02:37Z")

</div>

We can do

```julia
]add https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl#master

```

Surely it wouldn’t be a big deal to do the parsing inside the `add` function?

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [October 4, 2019, 8:23am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/4 "2019-10-04T08:23:57Z")

</div>

Its an architectural choice … Modularity and flexibility are improved by keeping parsers outside the `add`; this allows for a multitude of `pkg add` formats (i.e. a complicated parser) while simplifying the `add` functions code (at least in theory 😉 ):

```julia
Examples

  pkg> add Example
  pkg> add Example@0.5
  pkg> add Example#master
  pkg> add Example#c37b675
  pkg> add https://github.com/JuliaLang/Example.jl#master
  pkg> add git@github.com:JuliaLang/Example.jl.git
  pkg> add Example=7876af07-990d-54b4-ab0e-23690620f79a

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 4, 2019, 8:36am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/5 "2019-10-04T08:36:09Z")

</div>

> [@PetrKryslUCSD](#):
>
> Surely it wouldn’t be a big deal to do the parsing inside the `add` function?

It would be a pretty big deal.

But with [Add a more concise way to call the API functions by KristofferC · Pull Request #1358 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/pull/1358) you will (if we merge it) be able to write

```julia
Pkg.add(url = "http:...")

```

which is a bit more convenient.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 4, 2019, 10:08am UTC](https://discourse.julialang.org/t/pkg-add-with-a-url/29475/6 "2019-10-04T10:08:33Z")

</div>

I see. Fair enough. Thanks.
