# Error: Package not found in current path?

**URL:** <https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187>\
**Category:** Package Management\
**Tags:** question, package\
**Created:** [April 28, 2022, 4:36am UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187 "2022-04-28T04:36:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 28, 2022, 4:36am UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/1 "2022-04-28T04:36:32Z")

</div>

This post concerns the following error:  
`ArgumentError: Package TestPkg not found in current path`

I started a new project `TestPkg` and ran into the above error. The steps I followed are as follows:

1. I created a folder with the name `TestPkg`.
2. I ran Julia REPL and activated the environment `TestPkg` using `] activate.`
3. I added a package (say `Flux.jl`) using `] add Flux`. This created `Project.toml` and `Manifest.toml` files.
4. Next, I created two folders `src` and `test` inside `TestPkg` folder.
5. Then, I added a file `TestPkg.jl` inside the `src` folder and wrote the following content inside it:

```julia
module TestPkg
end

```

1. Next, I create a file `runtests.jl` inside the `test` folder and added the following content inside it:

```julia
using TestPkg
using Test
@test true

```

1. Now, when I execute `runtests.jl` in the Julia REPL (with `TestPkg` environment activated) I run into the above-mentioned error.

Can someone point out what exactly is the issue here? Thank you.

---

<div class="post-metadata">

**Author:** ![Salmon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salmon/32/22968_2.png) [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Post date:** [April 28, 2022, 12:37pm UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/2 "2022-04-28T12:37:45Z")

</div>

~~I think the file does not get evaluated in the current environment, but rather the environment that it is located in. You could try checking whether it works after you explicitly activate the environment in the file something like `using Pkg;Pkg.activate(“/pathTo/TestPkg”)~~

edit: Forget the above, the environment should remain. Maybe the reason is that your method creates just an environment which is not quite the same as a package that can actually be included? I am not entirely sure.  
In any case, do you know that you can create a new Package simply via `]generate TestPkg` instead?  
After that works, maybe as a further check in between you could try

```julia
]activate TestPkg
using TestPkg

```

If that also works, you can create your test file. By the way, another way to test your package is to run `]test TestPkg`. Then it seems the testing file is executed in the correct environment.  
I think your approach should also be fine though and its probably easier to test during your development flow (Assuming you also use Revise).  
Hope that helps

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 28, 2022, 5:12pm UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/3 "2022-04-28T17:12:30Z")

</div>

I know there are `generate PkgName` and [PkgTemplates](https://github.com/invenia/PkgTemplates.jl) that can automatically generate the required files and create the right environment; however, I was just curious to see what if I do it manually. In theory, it should still work.

Anyway, what I found was the way I was doing is not wrong, but my steps missed the part of specifying the name of the package in the `Project.toml` file. My `Project.toml` file looked like

```julia
[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"

```

Instead, it should look like:

```julia
name = "TestPkg"

[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"

```

This apparently resolves the error.  
Let me know if it makes sense. And thanks for your inputs! 🙂

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [April 28, 2022, 7:02pm UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/4 "2022-04-28T19:02:51Z")

</div>

You will also need an `uuid` field in `Project.toml`. I’m actually writing on a package creation tutorial for LocalRegistry. It’s unfinished (and has been for quite some time, just committed what I had) but you might find something of interest in its current state: [LocalRegistry.jl/create\_minimal\_package.md at tutorial · GunnarFarneback/LocalRegistry.jl · GitHub](https://github.com/GunnarFarneback/LocalRegistry.jl/blob/tutorial/docs/tutorials/create_minimal_package.md).

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 28, 2022, 7:38pm UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/5 "2022-04-28T19:38:50Z")

</div>

Although it is true that `uuid` will be required but it’s not mandatory at the development stage. What I mean is I was able to resolve the error I mentioned just by adding the `name` of the package in `Project.toml` file. Correct me if I am wrong. In short, I can work on the package (code and run it successfully from within its own environment) as long as I have its name specified in the `Project.toml` file.

And as you mention in the tutorial we can use `using UUIDs; uuid4()` to generate one when we want. Thanks for the reference to your tutorial though. I will keep an eye on it! 🙂

---

<div class="post-metadata">

**Author:** ![devanshu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/devanshu/32/37104_2.png) [@devanshu](https://discourse.julialang.org/u/devanshu)\
**Post date:** [January 25, 2023, 7:19am UTC](https://discourse.julialang.org/t/error-package-not-found-in-current-path/80187/6 "2023-01-25T07:19:07Z")

</div>

Hey,

What if I have multiple modules in my `src` folder?

The packages I am using in other modules, which are imported in the `TestPkg` file are not found in the path!

Thanks!
