I am experimenting with creation of my first package called OHTLCSM.jl. I followed the steps at the link below to add the package to my local repository:
Link: Simple Package Tutorial
StaticArrays.jl was among the dependencies I added from the repl via:
(@v1.5) pkg > activate .
(OHTLCSM) pkg > add StaticArrays Updating registry at `C:\Users\myusername\.julia\registries\General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
No Changes to `C:\Users\myusername\.julia\dev\OHTLCSM\Project.toml`
No Changes to `C:\Users\myusername\.julia\dev\OHTLCSM\Manifest.toml`
(@v1.5) pkg > activate
Activating environment at `C:\Users\myusername\.julia\environments\v1.5\Project.toml`
The package pre-compiles ok, but I get the following error when I run the one function in the package:
UndefVarError: SVector not defined
It seems like the dependency was not established properly. Is the procedure I used above valid? The code works fine outside the package environment.
Is it necessary to include the
using StaticArrays statement inside the module if dependencies have been added via the repl?
add makes it available, but to actually use it in your module you need to
import the module
Just to be clear, I would need to include it inside the module, like this?
#my function that uses StaticArrays.jl as a dependency
I added the line:
inside the module as shown in my previous post. I now get the following warning:
┌ Info: Precompiling OHTLCSM [792a8791-1285-4c47-952b-f0f8acb5a785]
└ @ Base loading.jl:1278
┌ Warning: Package OHTLCSM does not have StaticArrays in its dependencies:
│ - If you have OHTLCSM checked out for development and have
│ added StaticArrays 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 OHTLCSM
└ Loading StaticArrays into OHTLCSM from project dependency, future warnings for OHTLCSM are suppressed.
I tried the resolve() function as it states, but I continue to get the warning. However, the package seems to work fine. Any suggestions as to why I still get this warning?
You still have to activate/instantiate the package OHTLCSM. Then
using OHTLCSM should run without a warning.
For the benefit of any other folks who are also very new to this process, I assume by activate/instantiate you mean execution of:
(@v1.5) pkg> add OHTLCSM
I had not done that, but assumed this is what you meant and it did fix the problem.
Actually, no. I assumed the mode where one has a folder with the package. One could then start Julia in that folder and activate/instantiate followed by
Ok, that makes sense as well. Thank you.
No, “activate” and “instantiate” are terms specific to the Julia package manager here, and they refer to literally using the
pkg> activate and
pkg> instantiate commands. You can learn more about what those commands do over at Pkg · The Julia Language
Following the steps listed in the link on my previous post I entered shell from the repl and cd’d to the package folder. I then entered
activate . , then I added dependencies, finally I exited with
activate. However, I did not use
instantiate. When I added my package in the repl with
add OHTLCSM it seemed to fix the problem I was having. Is that a lucky accident or did that also instantiate?
It sounds like you did everything right.
instantiate takes an existing
Manifest and installs all of the packages listed in those files for the active package environment. Since you’ve already installed those packages via
pkg> add in this environment, there is nothing for
instantiate to do.