StatisticalRethinkingJulia / StatisticalRethinking.jl

Julia package with selected functions in the R package `rethinking`. Used in the SR2... projects.
MIT License
385 stars 32 forks source link

Weird dependency error #143

Closed Shmuma closed 2 years ago

Shmuma commented 2 years ago

Some time ago I start getting the error on initial import of the StatisticalRethinking. It happens only if Turing is imported first:

using Turing
using StatisticalRethinking

The error message is

┌ Warning: Error requiring `MCMCChains` from `StatisticalRethinking`
│   exception = (ErrorException("cannot assign a value to variable MCMCChains.MCMCChains from module StatisticalRethinking"), Union{Ptr{Nothing}, Base.InterpreterIP}[Ptr{Nothing} @0x00007fa4d6c81a7f, Ptr{Nothing} @0x00007fa4d6d101df, Ptr{Nothing} @0x00007fa4d6d31b3d, Ptr{Nothing} @0x00007fa4d6d14968, Ptr{Nothing} @0x00007fa4d6d15297, Base.InterpreterIP in top-level CodeInfo for StatisticalRethinking at statement 0, Ptr{Nothing} @0x00007fa4d6d30b31, Ptr{Nothing} @0x00007fa4d6d32949, Ptr{Nothing} @0x00007fa48e9a7f01, Ptr{Nothing} @0x00007fa48e9a7f2c, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d13f15, Ptr{Nothing} @0x00007fa4d6d13bce, Ptr{Nothing} @0x00007fa4d6d14811, Ptr{Nothing} @0x00007fa4d6d14b90, Ptr{Nothing} @0x00007fa4d6d1504a, Base.InterpreterIP in MethodInstance for err(::Any, ::Module, ::String) at statement 2, Ptr{Nothing} @0x00007fa48e9a7e77, Ptr{Nothing} @0x00007fa48e9a7e8c, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d13f15, Ptr{Nothing} @0x00007fa4d6d13bce, Ptr{Nothing} @0x00007fa4d6d148a5, Ptr{Nothing} @0x00007fa4d6d14b90, Ptr{Nothing} @0x00007fa4d6d1504a, Base.InterpreterIP in MethodInstance for withpath(::Any, ::String) at statement 10, Ptr{Nothing} @0x00007fa48e9a7df3, Ptr{Nothing} @0x00007fa48e9a7e1c, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d13f15, Ptr{Nothing} @0x00007fa4d6d13bce, Ptr{Nothing} @0x00007fa4d6d14811, Ptr{Nothing} @0x00007fa4d6d1504a, Base.InterpreterIP in MethodInstance for listenpkg(::Any, ::Base.PkgId) at statement 3, Ptr{Nothing} @0x00007fa48e9a7475, Ptr{Nothing} @0x00007fa48e9a75fc, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d304b5, Ptr{Nothing} @0x00007fa4d6d2617c, Ptr{Nothing} @0x00007fa499a24389, Ptr{Nothing} @0x00007fa499aaf62f, Ptr{Nothing} @0x00007fa499ab18a0, Ptr{Nothing} @0x00007fa499ab3c1d, Ptr{Nothing} @0x00007fa499ac3cec, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d2fcd1, Ptr{Nothing} @0x00007fa4d6d31d97, Ptr{Nothing} @0x00007fa4d6d30d7c, Ptr{Nothing} @0x00007fa4d6d32949, Ptr{Nothing} @0x00007fa499a9faec, Ptr{Nothing} @0x00007fa499a9fe89, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa499a9c9e3, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d08546, Ptr{Nothing} @0x00007fa499a6c7ee, Ptr{Nothing} @0x00007fa499a6ca1e, Ptr{Nothing} @0x00007fa499a6ca3c, Ptr{Nothing} @0x00007fa4d6cf7769, Ptr{Nothing} @0x00007fa4d6d18c9a, Ptr{Nothing} @0x0000000000000000])
└ @ Requires /home/shmuma/.julia/packages/Requires/7Ncym/src/require.jl:49

This appears only on initial import, if I restart the cell, it works without warnings and works properly.

If I add Optim import, the message changes:

using Optim
using Turing
using StatisticalRethinking

┌ Warning: Package StatisticalRethinking does not have Optim in its dependencies:
│ - If you have StatisticalRethinking checked out for development and have
│   added Optim as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with StatisticalRethinking
│ Loading Optim into StatisticalRethinking from project dependency, future warnings for StatisticalRethinking are suppressed.
└ @ nothing nothing:910
┌ Warning: Error requiring `MCMCChains` from `StatisticalRethinking`
│   exception = (ErrorException("cannot assign a value to variable MCMCChains.MCMCChains from module StatisticalRethinking"), Union{Ptr{Nothing}, Base.InterpreterIP}[Ptr{Nothing} @0x00007f36d181da7f, Ptr{Nothing} @0x00007f36d18ac1df, Ptr{Nothing} @0x00007f36d18cdb3d, Ptr{Nothing} @0x00007f36d18b0968, Ptr{Nothing} @0x00007f36d18b1297, Base.InterpreterIP in top-level CodeInfo for StatisticalRethinking at statement 0, Ptr{Nothing} @0x00007f36d18ccb31, Ptr{Nothing} @0x00007f36d18ce949, Ptr{Nothing} @0x00007f3689566731, Ptr{Nothing} @0x00007f368956675c, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18aff15, Ptr{Nothing} @0x00007f36d18afbce, Ptr{Nothing} @0x00007f36d18b0811, Ptr{Nothing} @0x00007f36d18b0b90, Ptr{Nothing} @0x00007f36d18b104a, Base.InterpreterIP in MethodInstance for err(::Any, ::Module, ::String) at statement 2, Ptr{Nothing} @0x00007f36895666a7, Ptr{Nothing} @0x00007f36895666bc, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18aff15, Ptr{Nothing} @0x00007f36d18afbce, Ptr{Nothing} @0x00007f36d18b08a5, Ptr{Nothing} @0x00007f36d18b0b90, Ptr{Nothing} @0x00007f36d18b104a, Base.InterpreterIP in MethodInstance for withpath(::Any, ::String) at statement 10, Ptr{Nothing} @0x00007f3689566623, Ptr{Nothing} @0x00007f368956664c, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18aff15, Ptr{Nothing} @0x00007f36d18afbce, Ptr{Nothing} @0x00007f36d18b0811, Ptr{Nothing} @0x00007f36d18b104a, Base.InterpreterIP in MethodInstance for listenpkg(::Any, ::Base.PkgId) at statement 3, Ptr{Nothing} @0x00007f3689564225, Ptr{Nothing} @0x00007f36895643ac, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18cc4b5, Ptr{Nothing} @0x00007f36d18c217c, Ptr{Nothing} @0x00007f369453b389, Ptr{Nothing} @0x00007f36945c628f, Ptr{Nothing} @0x00007f36945c8500, Ptr{Nothing} @0x00007f36945ca87d, Ptr{Nothing} @0x00007f36945d077c, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18cbcd1, Ptr{Nothing} @0x00007f36d18cdd97, Ptr{Nothing} @0x00007f36d18ccd7c, Ptr{Nothing} @0x00007f36d18ce949, Ptr{Nothing} @0x00007f36945b6aec, Ptr{Nothing} @0x00007f36945b6e89, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36945b39e3, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18a4546, Ptr{Nothing} @0x00007f36945837ee, Ptr{Nothing} @0x00007f3694583a1e, Ptr{Nothing} @0x00007f3694583a3c, Ptr{Nothing} @0x00007f36d1893769, Ptr{Nothing} @0x00007f36d18b4c9a, Ptr{Nothing} @0x0000000000000000])
└ @ Requires /home/shmuma/.julia/packages/Requires/7Ncym/src/require.jl:49

My dependencies are

      Status `~/work/rethinking/rethinking-2ed-julia/Project.toml`
  [488c2830] BSplines v0.3.2
  [336ed68f] CSV v0.9.6
  [d56128e0] Dagitty v0.0.1 `https://github.com/Shmuma/Dagitty.jl#main`
  [a93c6f00] DataFrames v1.2.2
  [31c24e10] Distributions v0.25.20
  [38e38edf] GLM v1.5.1
  [7073ff75] IJulia v1.23.2
  [5ab0869b] KernelDensity v0.6.3
  [b964fa9f] LaTeXStrings v1.2.1
  [429524aa] Optim v1.4.1
  [a68b5a21] ParetoSmooth v0.6.6
  [91a5bcdd] Plots v1.22.6
  [49802e3a] ProgressBars v1.4.0
  [2d09df54] StatisticalRethinking v4.3.0 `https://github.com/StatisticalRethinkingJulia/StatisticalRethinking.jl#master`
  [e1a513d0] StatisticalRethinkingPlots v0.9.3 `https://github.com/StatisticalRethinkingJulia/StatisticalRethinkingPlots.jl#master`
  [2913bbd2] StatsBase v0.33.11
  [4c63d2b9] StatsFuns v0.9.12
  [f3b207a7] StatsPlots v0.14.28
  [fce5fe82] Turing v0.18.0
goedman commented 2 years ago

Hi Max (@Shmuma),

Not sure if you had fixed it in your repo, but SR v4.4.2 should fix this. Partially it was a circular. If Optim.jl was present it required code that contained using Optim.

Let me know if you still see this.

Rob

Shmuma commented 2 years ago

Hi Rob,

Yes, the issue has gone. Thanks a lot!