How can I package julia program with dependencies using PackageCompiler?

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 ( showed, and it worked normally. However, when I added using Dates in the module, it throwed an error about dependency Dates.

module MyApp

using Dates

greet() = print(

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

end # module

And it reported:

⠙ [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?

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

] add Dates

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 MyApp.jl

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.