# How to find the path to the artifacts directory?

**URL:** <https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316>\
**Category:** General Usage\
**Created:** [March 7, 2024, 6:39pm UTC](https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316 "2024-03-07T18:39:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 7, 2024, 6:39pm UTC](https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316/1 "2024-03-07T18:39:35Z")

</div>

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
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

```

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [March 8, 2024, 9:59am UTC](https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316/2 "2024-03-08T09:59:15Z")

</div>

You need to load the module `Artifacts` for these functions.

```julia-repl
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"

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 8, 2024, 11:11am UTC](https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316/3 "2024-03-08T11:11:48Z")

</div>

Thanks. I thought I had tried `using Artifacts` as well, and maybe I did because this from the docs errors.

```julia
julia> using Artifacts

julia> @artifact"FFMPEG/bin/ffmpeg"
ERROR: LoadError: UndefVarError: `@artifact` not defined
in expression starting at REPL[7]:1

```

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [March 8, 2024, 12:48pm UTC](https://discourse.julialang.org/t/how-to-find-the-path-to-the-artifacts-directory/111316/4 "2024-03-08T12:48:03Z")

</div>

Well, the example is slightly wrong. String macros are invoked without the `@`. So it should read:

```julia-repl
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](https://pkgdocs.julialang.org/v1/artifacts/)  
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.
