# Cannot get package directory with dependencies to work

**URL:** <https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187>\
**Category:** General Usage\
**Created:** [November 2, 2024, 10:00pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187 "2024-11-02T22:00:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [November 2, 2024, 10:00pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187/1 "2024-11-02T22:00:22Z")

</div>

Here is an example: I create a directory `~/Julia/ExamplePackage` with a `Project.toml`

```julia
[deps]
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"

```

and a file `src/ExamplePackage.jl` with contents

```julia
module ExamplePackage
using MacroTools
end

```

My `LOAD_PATH` contains `~/Julia`. Then I start Julia in my home directory and say

```julia
julia> using ExamplePackage
[Info: Precompiling ExamplePackage [471cb73a-b2fc-536a-893f-35a09b8f328a] 
ERROR: LoadError: ArgumentError: Package MacroTools [1914dd2f-81c6-5fcd-8719-6d5c9610ff09] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

```

Saying `instantiate` in this situation (or in the package directory with `julia --project=.`) doesn’t help, neither does adding a UUID to the `Project.toml`. If I replace `MacroTools` with a package like `Test` that doesn’t need to be downloaded, then it works.

What am I missing?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 2, 2024, 10:38pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187/2 "2024-11-02T22:38:27Z")

</div>

> [@matthias314](#):
>
> My `LOAD_PATH` contains `~/Julia`.

Why? If you use packages, don’t modify the default load path.

Instead, either push your package to a git repository. Without registering it you can still do:

```julia
using Pkg
pkg"add <URL of my package>

```

If you don’t want that and want to work only locally, you can still do

```julia
using Pkg
Pkg.develop(path="MyJuliaPackages/Package.jl")

```

to add your local package to your main project.

First you have to add your package to your project, then you can do `using ExamplePackage`.

---

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [November 2, 2024, 11:12pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187/3 "2024-11-02T23:12:44Z")

</div>

What’s wrong with using package directories? They are described [in the manual](https://docs.julialang.org/en/v1/manual/code-loading/#Package-directories). My (possibly wrong) understanding is that if a package directory is in the `LOAD_PATH`, then one can load the corresponding package via `using`. This works for me as long as there are no dependencies. Is it supposed to work with dependencies? If not, how are package directories supposed to be used?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [November 2, 2024, 11:36pm UTC](https://discourse.julialang.org/t/cannot-get-package-directory-with-dependencies-to-work/122187/4 "2024-11-02T23:36:19Z")

</div>

I never used package directories, so I cannot explain how to use them.
