# Module with Main.BakedPackage in its dependencies

**URL:** <https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300>\
**Category:** Internals & Design\
**Created:** [February 12, 2022, 4:06pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300 "2022-02-12T16:06:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1ozturkbe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1ozturkbe/32/16461_2.png) [@1ozturkbe](https://discourse.julialang.org/u/1ozturkbe)\
**Post date:** [February 12, 2022, 4:06pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/1 "2022-02-12T16:06:24Z")

</div>

I have been working on a package for a while, that uses another package that is baked into Main by necessity (which I will called `Main.BakedPackage` for now). Its format is the following:

```julia
module MyPackage
    ...
    using Main.BakedPackage
    ...
end

```

I want to be able to call `Pkg.add("MyPackage")`, so I can call `using MyPackage` from any Julia terminal. But since I cannot add `Main` or `Main.BakedPackage` to the Project.toml of MyPackage, I always get the following error:  
**ERROR: LoadError: ArgumentError: Package MyPackage does not have Main in its dependencies:**  
Is there a way to get around this, or do I always have to call `include("MyPackage.jl"); using .MyPackage` every time I want to use it? This is really cumbersome, so your help is appreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [February 12, 2022, 11:38pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/2 "2022-02-12T23:38:26Z")

</div>

How can you be sure that BackedPackage is always in Main? It looks like a conditional dependency rather than a dependency? Tho it’s not actually a solution but more a workaround, but maybe you want to check Requires.jl?

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fingolfin/32/6033_2.png) [@fingolfin](https://discourse.julialang.org/u/fingolfin)\
**Post date:** [February 13, 2022, 10:22am UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/3 "2022-02-13T10:22:20Z")

</div>

> [@1ozturkbe](#):
>
> another package that is baked into Main by necessity

Why is it necessary? And how exactly do you “bake it in”?

---

<div class="post-metadata">

**Author:** ![1ozturkbe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1ozturkbe/32/16461_2.png) [@1ozturkbe](https://discourse.julialang.org/u/1ozturkbe)\
**Post date:** [February 13, 2022, 11:01am UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/4 "2022-02-13T11:01:10Z")

</div>

It’s necessary since it is a closed source package, and requires a pre-built system image of Julia with BakedPackage and its dependencies (by changing sys.so [Linux] or sys.dll [Windows] directly). See here: [System Image Building · The Julia Language](https://docs.julialang.org/en/v1/devdocs/sysimg/)

---

<div class="post-metadata">

**Author:** ![1ozturkbe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1ozturkbe/32/16461_2.png) [@1ozturkbe](https://discourse.julialang.org/u/1ozturkbe)\
**Post date:** [February 13, 2022, 11:02am UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/5 "2022-02-13T11:02:51Z")

</div>

You can only be sure if the user has gone through the same install process for BakedPackage. And I don’t know what you mean by a conditional dependency; it’s not conditional because BakedPackage has to be in Main for my package to work. I will check out Requires.jl.

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [February 13, 2022, 12:43pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/6 "2022-02-13T12:43:09Z")

</div>

If it has to be Main then that’s a dependency you should just depend on this package

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fingolfin/32/6033_2.png) [@fingolfin](https://discourse.julialang.org/u/fingolfin)\
**Post date:** [February 13, 2022, 1:11pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/7 "2022-02-13T13:11:17Z")

</div>

A closed source package can be done without a custom sysimage (eg via a private registry). So I am guessing you have some other reasons for a custom sysimage?

---

<div class="post-metadata">

**Author:** ![1ozturkbe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1ozturkbe/32/16461_2.png) [@1ozturkbe](https://discourse.julialang.org/u/1ozturkbe)\
**Post date:** [February 13, 2022, 1:51pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/8 "2022-02-13T13:51:05Z")

</div>

Main.BakedPackage is not mine, so I don’t get to choose how it’s implemented unfortunately. And @Roger-luo, I wish, but since the package is baked into Main, you can’t actually add it as a dependency in the usual way.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [February 13, 2022, 2:18pm UTC](https://discourse.julialang.org/t/module-with-main-bakedpackage-in-its-dependencies/76300/9 "2022-02-13T14:18:57Z")

</div>

Frankly you’re in a suuuuper weird scenario. Despite the name, `Main.BakedPackage` is not a package, it’s just a Module.

The author of the code should really have made an actual package and baked that in to the sysimage then you could do `using BakedPackage`. This is how the standard packages like Pkg work.
