# Pkg.add(PKG,VER) Version Ignored - Workarounds?

**URL:** <https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270>\
**Category:** General Usage\
**Tags:** package, packages\
**Created:** [October 5, 2017, 7:33pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270 "2017-10-05T19:33:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wibble](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wibble/32/906_2.png) [@wibble](https://discourse.julialang.org/u/wibble)\
**Post date:** [October 5, 2017, 7:33pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270/1 "2017-10-05T19:33:12Z")

</div>

Recent versions of HDF5 and OffsetArrays seem to be incompatible with Julia 0.6.0 because of the change from Range to AbstractRange, but `Pkg.add(PKG)` just installs the latest. I believe I’ve found the latest compatible versions by looking through their repo histories (0.8.5 and 0.4.0, respectively), but `Pkg.add(PKG,VER)` silently ignores the provided version.

Is there a workaround for this?

I can’t `Pkg.pin()` before `add()`ing. I can install the latest and then `pin()` to an older version, but then how do I get Julia to see the pin and downgrade?

---

<div class="post-metadata">

**Author:** ![wibble](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wibble/32/906_2.png) [@wibble](https://discourse.julialang.org/u/wibble)\
**Post date:** [October 9, 2017, 7:58pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270/2 "2017-10-09T19:58:30Z")

</div>

Discovered a workaround by fiddling with it on my own. Doing `Pkg.update()` followed by `Pkg.clone()` to get the package, and _then_ using `Pkg.pin()` seems to do the trick.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [October 9, 2017, 8:40pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270/3 "2017-10-09T20:40:29Z")

</div>

I just ran all the HDF5.jl and OffsetArrays.jl tests on Julia v0.6.0, and they all pass with the latest tagged versions of both packages (v0.8.6 and v0.4.2). What results are you getting that make you think they’re not compatible?

---

<div class="post-metadata">

**Author:** ![wibble](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wibble/32/906_2.png) [@wibble](https://discourse.julialang.org/u/wibble)\
**Post date:** [October 9, 2017, 9:41pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270/4 "2017-10-09T21:41:28Z")

</div>

They both _install_ fine (`Pkg.add()` succeeds), but upon `using` either I get e.g.

```julia
INFO: Precompiling module OffsetArrays.
ERROR: LoadError: UndefVarError: AbstractRange not defined
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:569
 [2] include(::String) at ./sysimg.jl:14
 [3] anonymous at ./<missing>:2
while loading /root/.julia/v0.6/OffsetArrays/src/OffsetArrays.jl, in expression starting on line 145

```

Both fail because their latest code uses the AbstractRange type instead of Range, which appears to be a change that’s in the repo slated for Julia 0.7. HDF5 0.8.5 and OffsetArrays 0.4.0 (as well as FFTViews 0.0.2, I’ve recently found) are what work for me—all versions prior to their changing from Range to AbstractRange.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [October 9, 2017, 10:37pm UTC](https://discourse.julialang.org/t/pkg-add-pkg-ver-version-ignored-workarounds/6270/5 "2017-10-09T22:37:02Z")

</div>

Ah, I see. I think the issue is actually that your version of `Compat.jl` is out of date (possibly pinned to an old version). On v0.6.0, I get:

```julia
julia> Pkg.installed("OffsetArrays")
v"0.4.2"

julia> using OffsetArrays

```

The reason this works is that Compat provides an alias in 0.6:

```julia
julia> using Compat

julia> Compat.AbstractRange
Range

```

which is how OffsetArrays gets its `AbstractRange` type.

I suspect that your version of Compat is pinned to before that alias was added.
