How come I can't install the latest version of StatsBase?

I am running Julia 1.1 and Windows 10. I can’t seem to install StatsBase 0.30 as I get this error when I ]pin StatsBase@0.30.

The error seems to suggest that Optim.jl restricts StatsBase to 0.29 but when I looked at the REQUIRE for Optim.jl it simply says StatsBase without specifying a version. So what’s stopping the upgrade? I can remove Optim and whatever other package but then why can’t I just upgrade StatsBase?

ERROR: Unsatisfiable requirements detected for package StatsBase [2913bbd2]:
 StatsBase [2913bbd2] log:
 ├─possible versions are: [0.1.0, 0.2.0-0.2.1, 0.2.3-0.2.10, 0.3.0-0.3.13, 0.4.0-0.4.4, 0.5.0-0.5.3, 0.6.0-0.6.16, 0.7.0-0.7.4, 0.8.0-0.8.3, 0.9.0, 0.10.0, 0.11.0-0.11.1, 0.12.0, 0.13.0-0.13.1, 0.14.0-0.14.1, 0.15.0, 0.16.0-0.16.1, 0.17.0, 0.18.0, 0.19.0-0.19.5, 0.20.0-0.20.1, 0.22.0, 0.23.0-0.23.1, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.0-0.28.1, 0.29.0, 0.30.0] or uninstalled
 ├─restricted to versions 0.30 by an explicit requirement, leaving only versions 0.30.0
 └─restricted by compatibility requirements with Optim [429524aa] to versions: [0.1.0, 0.2.0-0.2.1, 0.2.3-0.2.10, 0.3.0-0.3.13, 0.4.0-0.4.4, 0.5.0-0.5.3, 0.6.0-0.6.16, 0.7.0-0.7.4, 0.8.0-0.8.3, 0.9.0, 0.10.0, 0.11.0-0.11.1, 0.12.0, 0.13.0-0.13.1, 0.14.0-0.14.1, 0.15.0, 0.16.0-0.16.1, 0.17.0, 0.18.0, 0.19.0-0.19.5, 0.20.0-0.20.1, 0.22.0, 0.23.0-0.23.1, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.0-0.28.1, 0.29.0] — no versions left
   └─Optim [429524aa] log:
     ├─possible versions are: [0.1.0-0.1.7, 0.2.0, 0.3.0-0.3.1, 0.4.0-0.4.7, 0.5.0, 0.6.0-0.6.1, 0.7.0-0.7.5, 0.7.7-0.7.8, 0.9.0-0.9.3, 0.10.0-0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.14.0-0.14.1, 0.15.0-0.15.3, 0.16.0, 0.17.0-0.17.2, 0.18.0-0.18.1] or uninstalled
     └─restricted to versions 0.18.1 by an explicit requirement, leaving only versions 0.18.1

I think the problem is that StatsBase has migrated to the new Project.toml based system but not Optim. I think you either have to add a Project.toml to your Optim copy or remove the one in StatsBase.

That should not matter.

The problem is that Optim does not support StatsBase 0.30 (according to the registry): https://github.com/JuliaRegistries/General/blob/37cf47c862d8ae34197d14cf52741965e2c9f658/O/Optim/Compat.toml#L44

It seems to be resolved now.

In my case, it was due to Distributions package. I first installed Distributions and the version got installed was 0.19. When I tried to install StatsBase, it gave a similar error. So I removed Distributions and then reinstalled StatsBase. It went fine. Subsequently I reinstalled Distributions and the package version installed is 0.18.