Searching seemed to lead to things like @artifact_str
but all this error (???).
I need to programmatically get the full path of ~/.julia/artifacts
but taking into account too that the JULIA_DEPOT_PATH
may have been set.
julia> @artifact_str
ERROR: LoadError: UndefVarError: `@artifact_str` not defined
in expression starting at REPL[2]:1
julia> Artifacts.@artifact_str
ERROR: LoadError: UndefVarError: `Artifacts` not defined
in expression starting at REPL[4]:1
You need to load the module Artifacts
for these functions.
julia> using Artifacts
help?> @artifact_str
macro artifact_str(name)
Return the on-disk path to an artifact. Automatically looks the artifact up
by name in the project's (Julia)Artifacts.toml file. Throws an error on if
the requested artifact is not present. If run in the REPL, searches for the
toml file starting in the current directory, see find_artifacts_toml() for
more.
If the artifact is marked "lazy" and the package has using LazyArtifacts
defined, the artifact will be downloaded on-demand with Pkg the first time
this macro tries to compute the path. The files will then be left installed
locally for later.
If name contains a forward or backward slash, all elements after the first
slash will be taken to be path names indexing into the artifact, allowing
for an easy one-liner to access a single file/directory within an artifact.
Example:
ffmpeg_path = @artifact"FFMPEG/bin/ffmpeg"
Thanks. I thought I had tried using Artifacts
as well, and maybe I did because this from the docs errors.
julia> using Artifacts
julia> @artifact"FFMPEG/bin/ffmpeg"
ERROR: LoadError: UndefVarError: `@artifact` not defined
in expression starting at REPL[7]:1
Well, the example is slightly wrong. String macros are invoked without the @
. So it should read:
julia> artifact"FFMPEG/bin/ffmpeg"
ERROR: LoadError: Cannot locate '(Julia)Artifacts.toml' file when attempting to use artifact 'FFMPEG/bin/ffmpeg' in 'Main'
Stacktrace:
Which still errors because the active project does not contain an Artifacts.toml
.
I recommend you read the information about artifacts in the documentation of Pkg.jl: 8. Artifacts · Pkg.jl
But keep in mind that the functionality was moved to Julia itself in 1.6 and just the docs were not updated accordingly, so you need to do using Artifacts
and not using Pkg.Artifacts
like the docs suggest.
1 Like