Pkg.jl question

Hi,

Please see code below.

julia> pwd()
"C:\\home"

(@v1.8) pkg> generate HelloWorld
  Generating  project HelloWorld:
    HelloWorld\Project.toml
    HelloWorld\src\HelloWorld.jl

(@v1.8) pkg> activate c:\\home\\HelloWorld\\
  Activating project at `c:\home\HelloWorld`

(HelloWorld) pkg> st
  Installing known registries into `C:\home\usr\JULIA_DEPOT`
Project HelloWorld v0.1.0
Status `C:\home\HelloWorld\Project.toml` (empty project)

(HelloWorld) pkg> add PrettyTables@2.2.2
    Updating registry at `C:\home\usr\JULIA_DEPOT\registries\General.toml`
   Resolving package versions...
   Installed Formatting ────────────────── v0.4.2
   Installed DataValueInterfaces ───────── v1.0.0
   Installed DataAPI ───────────────────── v1.14.0
   Installed LaTeXStrings ──────────────── v1.3.0
   Installed Crayons ───────────────────── v4.1.1
   Installed OrderedCollections ────────── v1.5.0
   Installed StringManipulation ────────── v0.3.0
   Installed Tables ────────────────────── v1.10.1
   Installed Reexport ──────────────────── v1.2.2
   Installed IteratorInterfaceExtensions ─ v1.0.0
   Installed TableTraits ───────────────── v1.0.1
   Installed PrettyTables ──────────────── v2.2.2
    Updating `C:\home\HelloWorld\Project.toml`
βŒƒ [08abe8d2] + PrettyTables v2.2.2
    Updating `C:\home\HelloWorld\Manifest.toml`
  [a8cc5b0e] + Crayons v4.1.1
  [9a962f9c] + DataAPI v1.14.0
  [e2d170a0] + DataValueInterfaces v1.0.0
  [59287772] + Formatting v0.4.2
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [b964fa9f] + LaTeXStrings v1.3.0
  [bac558e1] + OrderedCollections v1.5.0
βŒƒ [08abe8d2] + PrettyTables v2.2.2
  [189a3867] + Reexport v1.2.2
  [892a3eda] + StringManipulation v0.3.0
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.10.1
  [56f22d72] + Artifacts
  [b77e0a4c] + InteractiveUtils
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [de0858da] + Printf
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [8dfed614] + Test
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll v1.0.1+0
  [4536629a] + OpenBLAS_jll v0.3.20+0
  [8e850b90] + libblastrampoline_jll v5.1.1+0
        Info Packages marked with βŒƒ have new versions available and may be upgradable.
Precompiling project...
  16 dependencies successfully precompiled in 10 seconds

At this step, I create test/runtests.jl.
Then I run test as you can see below.
Notice that during the test it is usung PrettyTables v2.2.2

(HelloWorld) pkg> test
     Testing HelloWorld
      Status `C:\Users\gitboy\AppData\Local\Temp\1\jl_y1mtu7\Project.toml`
  [25ccf548] HelloWorld v0.1.0 `C:\home\HelloWorld`
βŒƒ [08abe8d2] PrettyTables v2.2.2
      Status `C:\Users\gitboy\AppData\Local\Temp\1\jl_y1mtu7\Manifest.toml`
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.14.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [59287772] Formatting v0.4.2
  [25ccf548] HelloWorld v0.1.0 `C:\home\HelloWorld`
  [82899510] IteratorInterfaceExtensions v1.0.0
  [b964fa9f] LaTeXStrings v1.3.0
  [bac558e1] OrderedCollections v1.5.0
βŒƒ [08abe8d2] PrettyTables v2.2.2
  [189a3867] Reexport v1.2.2
  [892a3eda] StringManipulation v0.3.0
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.10.1
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [8f399da3] Libdl `@stdlib/Libdl`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [de0858da] Printf `@stdlib/Printf`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA v0.7.0 `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [8dfed614] Test `@stdlib/Test`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [e66e0078] CompilerSupportLibraries_jll v1.0.1+0 `@stdlib/CompilerSupportLibraries_jll`
  [4536629a] OpenBLAS_jll v0.3.20+0 `@stdlib/OpenBLAS_jll`
  [8e850b90] libblastrampoline_jll v5.1.1+0 `@stdlib/libblastrampoline_jll`
        Info Packages marked with βŒƒ have new versions available and may be upgradable.
     Testing Running tests...
     Testing HelloWorld tests passed

Now I exit HelloWorld and return to the main environment.
I β€œdev” HelloWorld then run the test.

(HelloWorld) pkg> activate
  Activating project at `C:\home\usr\JULIA_DEPOT\environments\v1.8`

(@v1.8) pkg> dev c:\\home\\HelloWorld
   Resolving package versions...
   Installed PrettyTables ─ v2.2.3
    Updating `C:\home\usr\JULIA_DEPOT\environments\v1.8\Project.toml`
  [25ccf548] + HelloWorld v0.1.0 `c:\home\HelloWorld`
    Updating `C:\home\usr\JULIA_DEPOT\environments\v1.8\Manifest.toml`
  [a8cc5b0e] + Crayons v4.1.1
  [9a962f9c] + DataAPI v1.14.0
  [e2d170a0] + DataValueInterfaces v1.0.0
  [59287772] + Formatting v0.4.2
  [25ccf548] + HelloWorld v0.1.0 `c:\home\HelloWorld`
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [b964fa9f] + LaTeXStrings v1.3.0
  [bac558e1] + OrderedCollections v1.5.0
  [08abe8d2] + PrettyTables v2.2.3
  [189a3867] + Reexport v1.2.2
  [892a3eda] + StringManipulation v0.3.0
  [3783bdb8] + TableTraits v1.0.1
  [bd369af6] + Tables v1.10.1
  [56f22d72] + Artifacts
  [2a0f44e3] + Base64
  [b77e0a4c] + InteractiveUtils
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [de0858da] + Printf
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [8dfed614] + Test
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll v1.0.1+0
  [4536629a] + OpenBLAS_jll v0.3.20+0
  [8e850b90] + libblastrampoline_jll v5.1.1+0

(@v1.8) pkg> test HelloWorld
     Testing HelloWorld
      Status `C:\Users\gitboy\AppData\Local\Temp\1\jl_iqmo6U\Project.toml`
  [25ccf548] HelloWorld v0.1.0 `c:\home\HelloWorld`
  [08abe8d2] PrettyTables v2.2.3
      Status `C:\Users\gitboy\AppData\Local\Temp\1\jl_iqmo6U\Manifest.toml`
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.14.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [59287772] Formatting v0.4.2
  [25ccf548] HelloWorld v0.1.0 `c:\home\HelloWorld`
  [82899510] IteratorInterfaceExtensions v1.0.0
  [b964fa9f] LaTeXStrings v1.3.0
  [bac558e1] OrderedCollections v1.5.0
  [08abe8d2] PrettyTables v2.2.3
  [189a3867] Reexport v1.2.2
  [892a3eda] StringManipulation v0.3.0
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.10.1
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [8f399da3] Libdl `@stdlib/Libdl`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [de0858da] Printf `@stdlib/Printf`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA v0.7.0 `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [8dfed614] Test `@stdlib/Test`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [e66e0078] CompilerSupportLibraries_jll v1.0.1+0 `@stdlib/CompilerSupportLibraries_jll`
  [4536629a] OpenBLAS_jll v0.3.20+0 `@stdlib/OpenBLAS_jll`
  [8e850b90] libblastrampoline_jll v5.1.1+0 `@stdlib/libblastrampoline_jll`
Precompiling project...
  2 dependencies successfully precompiled in 7 seconds. 14 already precompiled.
     Testing Running tests...
     Testing HelloWorld tests passed

Notice how it is now using PrettyTables 2.2.3.
I have added in the Project.toml file a section

[compat]
PrettyTables = "2.2.2"

But still when I run test HelloWorld it still uses version 2.2.3 of PrettyTables. Why is that?
Is there a way to constrain the version?

Thank you

This section describes [compat] entries and what they mean: 6. Compatibility Β· Pkg.jl

So it seems that I have to do :

[compat]
PrettyTables = "=2.2.2"

Now let’s assume I have a second package HelloWorld2 that uses PrettyTables 2.2.3. I constrain that package in the same way but to version 2.2.3.

Then when I try to dev this second package, I get:

ERROR: Unsatisfiable requirements detected for package PrettyTables

I am correct in saying that I have to find version of PrettyTables that works for both packages in order to be able to use them both at the same time in the REPL?
Does that mean that Julia package manager is not capable of using specific versions of some package for 2 projects that are running both at the same time?
Tks

Yes.

Yes, although this is really not about the package manager – you can only load one version of a package per process.

1 Like

Thank you for the explanation. So to conclude there is no way to import multiple versions of the same package like Rust can do.

1 Like