# New Pkg: Immediate Compile and Version Variable?

**URL:** <https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255>\
**Category:** Internals & Design\
**Created:** [August 11, 2018, 5:08pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255 "2018-08-11T17:08:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 11, 2018, 5:08pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/1 "2018-08-11T17:08:54Z")

</div>

I am beginning to use Julia 1.0. `Pkg.dir()` no longer seems to work (and has no docs). What has replaced it? `Pkg.status()` works differently. Alas, these are just minor questions. I have a reason for posting to development"

1. Should the default on `Pkg.add()` be to do the first-time compilation right away, too? Who would want to add a package and not run it? Is there a reason?

2. Do packages have a variable that tells the package manager whether they have been ported/tested on a particular julia version? (This is not just a minimum Julia version.) I am asking because `Glob` and `TimeSeries` have a successful `Pkg.add()`, but both flunk on first-time compilation (and I have a fresh julia 1.0). So I am wondering whether these two packages [as examples] have made the jump from 0.6 to 1.0. if they have, then not very successfully so. if they have not, then the `Pkg.add()` should have told me this.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 11, 2018, 5:14pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/2 "2018-08-11T17:14:53Z")

</div>

> [@iwelch](#):
>
> `Pkg.dir()` no longer seems to work (and has no docs). What has replaced it?

In 99.5% of cases you can replace it with `@ __DIR__ ` usage. Otherwise there is `Base.pathof`.

> [@iwelch](#):
>
> Should the default on `Pkg.add()` be to do the first-time compilation right away, too? Who would want to add a package and not run it? Is there a reason?

If you plan to add an extra package after it might be that you need to recompile anyway, so you do double work.

> [@iwelch](#):
>
> Do packages have a variable that tells the package manager whether they have been ported/tested on a particular julia version?

No, and in theory/in the future the package manager should not install packages, unless the package declares that it works. For example, when Julia v2.0 is released, packages that don’t explicitly support this will not be installable. See [https://docs.julialang.org/en/latest/stdlib/Pkg/#Compatibility-1](https://docs.julialang.org/en/latest/stdlib/Pkg/#Compatibility-1)

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 11, 2018, 6:05pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/3 "2018-08-11T18:05:46Z")

</div>

> [@fredrikekre](#):
>
> In 99.5% of cases you can replace it with `@ __DIR__ ` usage. Otherwise there is `Base.pathof` .
> 
> ![](https://global.discourse-cdn.com/julialang/original/3X/6/8/68312c78e76b70daa9a3f4ec9b0c21f382a2cb87.png) iwelch:

`@ __DIR__ ` just gives the cwd for me. It does not tell me where the (local) packages for this version are installed for me. can you please give an example of `Base.pathof()` usage?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 11, 2018, 6:08pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/4 "2018-08-11T18:08:28Z")

</div>

> [@iwelch](#):
>
> `@ __DIR__ ` just gives the cwd for me.

You should use this in the file which need to reach into the package.

> [@iwelch](#):
>
> can you please give an example of `Base.pathof()` usage?

```julia
using Example
Base.pathof(Example)

```

but again, try to use `@ __DIR__ `.

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 20, 2018, 10:52pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/5 "2018-08-20T22:52:35Z")

</div>

still can’t figure out how to obtain the version number of a package.

```julia
julia> using DataFrames

julia> Base.pathof(DataFrames)
"/Users/me/.julia/packages/DataFrames/utxEh/src/DataFrames.jl"

```

I need something like 0.11.3. I tried to

```julia
# grep -R -i version /Users/ivo/.julia/packages/DataFrames/utxEh/src/

```

to see if I could find a version string in a place, but failed.

On reflection, it would make sense to make an immediate compilation the default for `Pkg.add()`, especially in the REPL; but an optional keyword can suppress it .

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [August 21, 2018, 2:10am UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/6 "2018-08-21T02:10:48Z")

</div>

A version number, of there is one, is recorded in the manifest file. You can also call Pkg.installed().

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [August 21, 2018, 8:13am UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/7 "2018-08-21T08:13:18Z")

</div>

Doesn’t Pkg.status() tell you this?

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 21, 2018, 4:03pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/8 "2018-08-21T16:03:24Z")

</div>

Stefan, David—can you please give a simple use example?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [August 21, 2018, 4:08pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/9 "2018-08-21T16:08:37Z")

</div>

I think the request is for a snippet that, from within another package, obtains the version number of some specific installed package (or nothing if not installed).

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [August 21, 2018, 4:16pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/10 "2018-08-21T16:16:02Z")

</div>

I’m no expert… but will the following code do the trick?

```nohighlight
julia> using Pkg;
julia> Installed = Pkg.installed();
julia> Installed["PyPlot"]
v"2.6.0"

```

The response of `Pkg.installed()` is a dictionary. I guess if you use a key that doesn’t exist in your dictionary, there will be an error message.

Of course, you can then test the version:

```julia
julia> Installed["PyPlot"] < v"2.7"
true

```

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [August 21, 2018, 5:22pm UTC](https://discourse.julialang.org/t/new-pkg-immediate-compile-and-version-variable/13255/11 "2018-08-21T17:22:46Z")

</div>

thanks. I tried it on other computers, and I must have done something wrong. how odd. now it works.
