# Can't precompile dependencies to newly created packages

**URL:** <https://discourse.julialang.org/t/cant-precompile-dependencies-to-newly-created-packages/29294>\
**Category:** General Usage\
**Created:** [September 29, 2019, 3:18pm UTC](https://discourse.julialang.org/t/cant-precompile-dependencies-to-newly-created-packages/29294 "2019-09-29T15:18:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sairus7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sairus7/32/10816_2.png) [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Post date:** [September 29, 2019, 3:18pm UTC](https://discourse.julialang.org/t/cant-precompile-dependencies-to-newly-created-packages/29294/1 "2019-09-29T15:18:35Z")

</div>

I’m trying to add package dedendency to newly generated package environment, and if that depencency was not added to my main julia environment, using new package from main environment fails to precompile it. (Windows 10, Julia 1.2)

Steps to reproduce:

- In REPL:  
`]generate MyPkg`  
`]activate MyPkg`  
`]add LazyArrays` (or any other package instead of LazyArrays that you did NOT added earlier to your main environment)

- Add `using LazyArrays` to src\MyPkg.jl

- In REPL:  
`]instantiate`  
`using MyPkg` - at this point, using package from its own environment works fine.

- Restart Julia.

- In REPL:  
`using MyPkg`

> ERROR: LoadError: ArgumentError: Package LazyArrays [5078a376-72f3-5289-bfd5-ec5146d43c02] is required but does not seem to be installed:  
> – Run `Pkg.instantiate()` to install all recorded dependencies.

- Trying to `]instantiate` from main environment doesn’t help. But if I `]activate MyPkg` and `using MyPkg` from its own environment, all looks fine.

Being able to use a new package only from its own environment seems strange to me. Also, there are no errors when adding packages already added to main environment.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 29, 2019, 10:04pm UTC](https://discourse.julialang.org/t/cant-precompile-dependencies-to-newly-created-packages/29294/2 "2019-09-29T22:04:31Z")

</div>

You need to `add` or `dev` MyPkg in any environment where you want to use it.

So this should work:

```julia
>pkg dev path/to/MyPkg
>julia using MyPkg

```

I am actually surprised that you don’t get an error indicating that `MyPkg` cannot be found when you issue `using MyPkg` in a new REPL.
