# How can I package julia program with dependencies using PackageCompiler?

**URL:** <https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373>\
**Category:** General Usage\
**Tags:** question, package-compiler\
**Created:** [April 12, 2022, 10:04am UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373 "2022-04-12T10:04:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Supernova](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/supernova/32/37999_2.png) [@Supernova](https://discourse.julialang.org/u/Supernova)\
**Post date:** [April 12, 2022, 10:04am UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373/1 "2022-04-12T10:04:54Z")

</div>

I’m trying to package my Julia program with PackageCompiler, but I met a problem of dependencies.

I tried the simplest demo of MyApp as [Apps · PackageCompiler (julialang.github.io)](https://julialang.github.io/PackageCompiler.jl/dev/apps.html) showed, and it worked normally. However, when I added `using Dates` in the module, it throwed an error about dependency `Dates`.

```julia
module MyApp

using Dates

greet() = print(Dates.now())

function julia_main()::Cint
    # do something based on ARGS?
    greet()
    return 0 # if things finished successfully
end

end # module

```

And it reported:

```julia
⠙ [00m:12s] PackageCompiler: compiling incremental system imageArgumentError: Package MyApp does not have Dates in its dependencies:
- If you have MyApp checked out for development and have
  added Dates as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with MyApp

```

I have run `Pkg.resolve()` and nothing changed to `Project.toml` and `Manifest.toml`.

Is there any solution for this?

---

<div class="post-metadata">

**Author:** ![alastair-marshall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alastair-marshall/32/21418_2.png) [@alastair-marshall](https://discourse.julialang.org/u/alastair-marshall)\
**Post date:** [April 12, 2022, 4:47pm UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373/2 "2022-04-12T16:47:22Z")

</div>

Have you tried adding Dates as a dependency of your package?

```julia
] add Dates

```

---

<div class="post-metadata">

**Author:** ![Supernova](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/supernova/32/37999_2.png) [@Supernova](https://discourse.julialang.org/u/Supernova)\
**Post date:** [April 13, 2022, 3:04am UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373/3 "2022-04-13T03:04:23Z")

</div>

Yes, I have added Dates as a dependency, and the program runs normally before trying to package.

(I added a line `julia_main()` at the end of `MyApp.jl` to call the main function explicitly)

```julia
$ julia MyApp.jl
2022-04-13T10:51:32.398(base)

```

---

<div class="post-metadata">

**Author:** ![Supernova](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/supernova/32/37999_2.png) [@Supernova](https://discourse.julialang.org/u/Supernova)\
**Post date:** [April 15, 2022, 7:36am UTC](https://discourse.julialang.org/t/how-can-i-package-julia-program-with-dependencies-using-packagecompiler/79373/4 "2022-04-15T07:36:52Z")

</div>

Problem fixed. I deleted the previous `manifest.toml`, and copied the lines of the dependencies I used from the julia default `%HOMEPATH%/.julia/environments/v1.7/project.toml` to the `project.toml` in the current project. Then I re-packaged the project as the PackageCompiler documentation. A new `manifest.toml` was generated and the dependencies were also automatically added inside. To ensure the success of compilation, the line `julia_main()` I added above should be deleted (otherwise the last module named the project itself would not pass).

Finally the PackageCompiler worked normally. Meanwhile, before compilation I also updated the version of the project in `project.toml` by 0.0.1, and haven’t tested either it is necessary.
