RoboticExplorationLab / Altro.jl

MIT License
139 stars 41 forks source link

StaticArrays not installed while installing Altro #15

Closed hurak closed 3 years ago

hurak commented 3 years ago

After installing Altro into a clean environment (adding manually just RobotZoo to run the example), it appears that StaticArrays is not added automatically even though it is stated in Altro's Project.tom, .

(trying) pkg> status
Status `~/ownCloud/julia/pokus2/Project.toml`
  [5dcf52e5] Altro v0.2.0
  [74be38bb] RobotZoo v0.1.2
julia> using StaticArrays
ERROR: ArgumentError: Package StaticArrays not found in current path:
- Run `import Pkg; Pkg.add("StaticArrays")` to install the StaticArrays package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:893

I am still not quite fluent with Julia's Pkg system. Do I understand it incorrectly that if a package is mentioned in the Project.toml, then it is automatically installed? Here in order to get the Altro example going, I had to add StaticArrays manually.

bjack205 commented 3 years ago

This is a great question. I'm not 100% fluent on the package system, either (it's quite complex), but I will try to explain best I can.

tldr; StaticArrays is installed as a dependency with Altro. To actually use the package, you need to add it your environment.

Julia distinguishes between packages installed directly and those installed as dependencies from other packages. Packages installed directly via Pkg.add are added to the environment's Project.toml file, and will never change version on you unless explicitly asked (via Pkg.update).

Packages installed as dependencies are not added to the Project.toml file and are free to change version to meet the various requirements imposed by the installed packages. You will notice this whenever you install a new package, since it prints out all the dependencies that were added or changed version.

So while StaticArrays is technically installed when installing Altro, you can't actually import it (via using StaticArrays) until you install it. That way Julia can guarantee that you use the same version of StaticArrays each time you import it. Hopefully that answers your question!

As a side note, I'm in the process of updating the Altro ecosystem to support StaticArrays v1.0.

hurak commented 3 years ago

Many thanks.