Pkg.add() refuses to use the required version

I am using Julia 0.7. I have a clone of ModiaMath (version 0.2.1 for Julia 0.7) in HOME/.julia/dev and would like that this version is used in Modia (for Julia 0.7). When doing the following:

]activate HOME/.julia/dev/Modia
(Modia) pkg> add ModiaMath@0.2.1

Then the respond from julia 0.7 is:

(Modia) pkg> add ModiaMath@0.2.1
  Updating registry at `D:\otter\home\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package ModiaMath [67ccffd1]:
 ModiaMath [67ccffd1] log:
 ├─possible versions are: 0.2.0 or uninstalled
 └─restricted to versions 0.2.1 by an explicit requirement - no versions left

ModiaMath 0.2.0 (for Julia 0.6.4) is registered in METADATA. ModiaMath 0.2.1 (for Julia 0.7.0) is not yet registered in METADATA. I have made a pull request, but this is not yet accepted, because there are errors from the JuliaCIBot (https://github.com/JuliaLang/METADATA.jl/pull/16719), but with TravisCL (and locally on my machine) everything is fine. I do not understand what goes wrong in JuliaCIBot (https://juliarun-ci.s3.amazonaws.com/4d00da96f29ccc4439410866e3c4197211fe1896/pull_request_of_ModiaMath_on_julia_0_7.log). It might be that the installation of “PyCall” failed.

I am stuck and do not know how and where to continue. I hope someone can give some hints.

I believe you are looking for (Modia) pkg> dev <path/to/ModiaMath>@0.2.1.

As an example:

(v0.7) pkg> generate TestPkg
Generating project TestPkg:
    TestPkg/Project.toml
    TestPkg/src/TestPkg.jl

(v0.7) pkg> generate ExamplePkg
Generating project ExamplePkg:
    ExamplePkg/Project.toml
    ExamplePkg/src/ExamplePkg.jl

shell> cd ExamplePkg/
/mnt/c/Users/<snip>/Documents/projects/juliaDiscourse/ExamplePkg

(v0.7) pkg> activate .

(ExamplePkg) pkg> dev ../TestPkg
 Resolving package versions...
  Updating `Project.toml`
  [134171c0] + TestPkg v0.1.0 [`../TestPkg`]
  Updating `Manifest.toml`
  [134171c0] + TestPkg v0.1.0 [`../TestPkg`]

shell> cat Manifest.toml
[[TestPkg]]
path = "../TestPkg"
uuid = "134171c0-9f90-11e8-3327-2559784b8890"
version = "0.1.0"

shell> cat Project.toml
name = "ExamplePkg"
uuid = "181f3ec0-9f90-11e8-011b-b9690a97d3da"
authors = <snip>
version = "0.1.0"

[deps]
TestPkg = "134171c0-9f90-11e8-3327-2559784b8890"

As a note though, I’m not quite sure what the workflow for tracking the original repo after the PR has been merged is.

Nevermind, there it is in the documentation:

If dev is used on a local path, that path to that package is recorded and used when loading that package. The path will be recorded relative to the project file, unless it is given as an absolute path.

To stop tracking a path and use the registered version again, use free

Thanks for your respond. It helped a little bit. After many different tries, I finally managed to add a project.toml and manifest.toml file to Modia that includes the correct ModiaMath version.

Apologies, I missed that you were updating a package from 0.6.4 to 0.7 - I believe you could have generated the necessary Manifest.toml and Project.toml using (Modia) pkg> develop . when navigated to the location of your package and activating its environment. If a REQUIRE exists, the new Pkg seems (from my observations) to take the REQUIRE file and generate both Manifest and Project.toml from it.

There may be some inconsistencies though, as mentioned here.

Unfortunately, it still does not work. When making

(v0.7) pkg> activate HOME/.julia/dev/Modia
(Modia) pkg> status
Project Modia v0.2.0-beta.5
    Status `D:\otter\home\.julia\dev\Modia\Project.toml`
  [864edb3b] DataStructures v0.11.0
  [682c06a0] JSON v0.19.0
  [80923050] ModiaMath v0.2.1 #master (ModiaMath)
  [d330b81b] PyPlot v2.6.0
  [1986cc42] Unitful v0.11.0
  [37e2e46d] LinearAlgebra
  [de0858da] Printf

the ModiaMath version for julia v0.7 is used (ModiaMath v0.2.1). However, when making “import Modia” and running one of the examples, then ModiaMath v0.2.0 is used (which crashes under julia v0.7.0).

So yo have a folder named ModiaMath in your Modia directory that you have added so you are tracking it by what commits are on the master branch? If you want to track the actual file that are in the folder you can do dev ./ModiaMath or if you want to upgrade to the latest master branch in the ModiaMath repo you can do up ModiaMath.

Its working now with the right ModiaMath version (no crash). I made the following steps:

  1. Removed the directory “HOME/.julia/packages/ModiaMath”.
  2. (v0.7) pkg> activate HOME/.julia/dev/Modia
  3. (Modia) pgk> instantiate
  4. checked and indeed under “HOME/.julia/packages/ModiaMath/…” there was now the right ModiaMath version.

So, this is good. However, what I really would like to have is that Modia uses the current development version of ModiaMath which is placed under HOME/.julia/dev/ModiaMath. O tried your suggestion

(Modia) pkg> dev ../ModiaMath
   Cloning git-repo `../ModiaMath`
ERROR: failed to clone from ../ModiaMath, error: GitError(Code:ERROR, Class:Net, unsupported URL protocol)

but this gives an error. However, using “up ModiaMath” gives no error. However, when leaving julia and entering it again and making “import Modia”, suddenly an error occurs.

ERROR: LoadError: LoadError: ArgumentError: Package ModiaMath [67ccffd1-116d-535b-ad39-76a8fd0cbf71] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

O.k., made ]instantiate" and then I could run examples with Modia. However, when I exit julia and re-entering it again and making “import Modia”, then [ Info: Precompiling Modia [cb905087-75eb-5f27-8515-1ce0ec8e839e] and again the above error occurs (so “ModiaMath … does not seem to be installed”). The current status is therefore, that whenever I newly start julia, I have to make instantiate.

O.k. for whatever raeson in HOME/.julia/environments/v0.7, in the Manifest.toml file the following is present:

[[Modia]]
path = "D:\\otter\\home\\.julia\\dev\\Modia"
uuid = "cb905087-75eb-5f27-8515-1ce0ec8e839e"
version = "0.2.0+"

    [Modia.deps]
    DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
    JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
    LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
    ModiaMath = "67ccffd1-116d-535b-ad39-76a8fd0cbf71"
    Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
    PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
    SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
    Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
    Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[[ModiaMath]]
deps = ["DataFrames", "DataStructures", "Documenter", "LinearAlgebra", "Printf", "PyPlot", "StaticArrays", "Sundials", "Unitful"]
path = "D:\\otter\\home\\.julia\\dev\\ModiaMath"
uuid = "80923050-9e1b-11e8-0c9e-c9f8e684994a"
version = "0.2.1"
[[ModiaMath]]
deps = ["DataFrames", "DataStructures", "LinearAlgebra", "Printf", "PyPlot", "StaticArrays", "Sundials", "Test", "Unitful"]
git-tree-sha1 = "654a93e69233a1366cf47f3742ea8127c3ac39c0"
uuid = "67ccffd1-116d-535b-ad39-76a8fd0cbf71"
version = "0.2.0"

so two different ModiaMath versions and Modia refers to the wrong one. But the HOME/.julia/dev/Modia/project.toml file has the correct dependency:

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ModiaMath = "80923050-9e1b-11e8-0c9e-c9f8e684994a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
O.k. Deleted "HOME\.julia\environments\v0.7", left julia and entered julia again. Making `import Modia` gives an error
```
ERROR: ArgumentError: Package Modia not found in current path:
- Run `Pkg.add("Modia")` to install the Modia package.
```
So, the Modia version in HOME/.juliarc/dev/Modia is "somehow" not known. Making "]add Modia" gives errors:
```
(v0.7) pkg> add Modia
  Updating registry at `D:\otter\home\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `Modia`
  Updating git-repo `Modia`
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package ModiaMath [80923050]:
 ModiaMath [80923050] log:
 ├─ModiaMath [80923050] has no known versions!
 └─restricted to versions * by Modia [e4773e00] - no versions left
   └─Modia [e4773e00] log:
     ├─possible versions are: 0.2.0 or uninstalled
     └─Modia [e4773e00] is fixed to version 0.2.0-beta.5
```

Tried the commands
```
]
(v0.7) pkg> add HOME/.julia/dev/ModiaMath
(v0.7) pkg> add HOME/.julia/dev/Modia

import Modia
exit()
julia
import Modia
```

and this seem to finally work.

Sorry, for the confusing long session description above. I think everything boils now down to the only remaining open question:

In HOME/.julia/dev there are two git repositories - Modia and ModiaMath. I would like to use ALWAYS the actual version of Modia and ModiaMath that are stored here (so when I make a local change to HOME/.julia/dev/ModiaMath" and make “import Modia” (which uses ModiaMath), then I would like to utilize the version of ModiaMath that is stored in HOME/.julia/dev/ModiaMath and not the one that was here when I made the command “add dev/ModiaMath”. Otherwise, it is a bit tedious to develop the two packages in parallel (but of course one can live with it).

Then you want to use develop.

1 Like

Thanks, this seems to work (however, I get now a crash in Julia that I did not get before; but most likely this is an issue with ModiaMath calling an external C-Code).