Cannot get package directory with dependencies to work

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

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

and a file src/ExamplePackage.jl with contents

module ExamplePackage
using MacroTools
end

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

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?

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:

using Pkg
pkg"add <URL of my package>

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

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.

What’s wrong with using package directories? They are described in the manual. 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?

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