I can't use the PackageCompiler

I am retrying to use PackageCompiler, for the second time (the first, I was unable to produce an executable, because it gave me error).
I am following - again - the instruction on
https://julialang.github.io/PackageCompiler.jl/dev/apps/

Well, today, i have no error, but 20 minutes have passed since I ran the command which should produce an executable and
nothing happens and it remains like this:

C:\Users\dario\.julia\packages\PackageCompiler\D8oaG\examples>julia -q --project
julia> using PackageCompiler
[ Info: Precompiling PackageCompiler [9b87118b-4619-50d2-8e1e-99f35a4d4d9d]

julia> create_app("MyApp","MyAppCompiled")
  Updating registry at `C:\Users\dario\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl`
  Updating git-repo `https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl`
 Installed Example ─ v0.5.3
[ Info: PackageCompiler: creating base system image (incremental=false)...
[ Info: PackageCompiler: creating system image object file, this might take a while...

What can I try?

What type of system are you on? If you have very little RAM and the OS has to use the swap spaces I can imagine it could get very slow.

I have this pc:
image

I have windows 10.

16 GB should be enough… Does it happen every time?

Oh … today it works!

I takes 14 min (why so much time !? is it normal? and big sized … 291MByte of app … ok, all julia inside, i think … but this is not a problem), but it is ended and I see MyApp.exe, that works.

Well, this was the examples i get from internet … now i will try to understand how compile my app that use Genie as external package …

Thanks, i will post again if i will find problems.

Really i would like to obtain an executable to pass to other pc.

I am trying to compiler my app (a web server app based on Genie), trying to adjust starting from the MyApp example.
I have this error, i undestand the i have not declared the use of Genie, but i don’t know how to do.
Since I’m a beginner, could you tell me how exactly to incorporate Genie?

ERROR: LoadError: ArgumentError: Package MyAppQuerere does not have Genie in its dependencies:
- If you have MyAppQuerere checked out for development and have
  added Genie 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 MyAppQuerere

Just

import Pkg
Pkg.add("Genie")

when you have your app project active.

I guess I didn’t get it right.

I thought I had to specify somewhere, among the files called Artifacts.toml, Manifest.toml (or other file), that the Genie package is needed.

I put a photo.

I started from the example on the web, of MyApp.

I created a MyAppQuerere,
and I went to make these moves. Most likely I left a lot more stuff, of the example, which I don’t need, but let’s say at least to begin to see if it is possible to compile …

So, I changed to precompile_app.jl by writing MyAppQuerere, which is mine.
Then I put the src folder, my two files, querere.jl where I have the functions, and web.jl which is what I launch to start the web app “doing julia.exe web.j” from the command line.

Then, I changed here, writing that I include my web.jl, which I thought should be done.

function julia_main()
    try
        include("web.jl")
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

Can you tell me what to do - considering i am a beginner?

Although Julia’s focus is not on creating standalone executables, it would be very important for me to be able to do so. I have to have an easy way to move my application made in Julia, from pc to pc …

Thanks for your patience.

Using something like include("web.jl") in the main function (which runs at runtime) is never going to work because when the App is shipped there will be no source files.

You removed a bit too much form the example App. You should keep the Project.toml, Manifest.toml and src folder. You can put in your include("web.jl") here: PackageCompiler.jl/MyApp.jl at aa58b9977b96aad7df6b971a51370713e1887fb4 · JuliaLang/PackageCompiler.jl · GitHub.

And then inside real_main:

you run the function you want that starts the application.

1 Like

A simple question for now: if i will obtain ax executable that works … can I leave an external files myExternalFile.jl into the /bin folder, using "include(“myExternalFile.jl”) ? In other words, is it possible to distribute standalone application in Julia, butbut leaving small external .jl files in the bin folder, and all works the same?

The second think … thank you very much, but I have not really understood how I can fix to successfully compile with PackageCompiler … this more than anything else because I am a beginner … i know … yes i am going a bit to much fast to my goal, i need to read more basics on Julia, i know … ok … but whether or not to adopt Julia depends on whether I can make standalone webapp applications, and i have to understand how difficult it is.

I managed without putting too much effort into setting up a web app - and that works I would say very well by launching “julia.exe web.jl” - now I only miss the possibility of distributing standalone.

I also asked the Genie developer if he gives me any help, since Genie did, so maybe he senses what I’m trying to do …

Right now, the only way to bundle extra files is using the Artifact system. In theory it is possible to add some arguments to create_app that would also bundle extra files. I don’t see any reason for bundling source files though, just include them in your app so they are compiled into the sysimage.

I had a small program in one file and it took about 10 minutes to compile, and I was told the slowness was normal. It seems to me, that you actually do not need standalone apps. For me, I could shave of 2-3 minutes with the incremental option. There’s also filter option to get relatively smaller apps. Your apps will not get faster, only slightly faster startup, likely not as issue for a web server (should never go down…). [I would like to know how to make the apps smaller and compiles faster, what it takes to fix PackageCompiler that way.]

Why I think you do not need standalone apps. Often they are to hide source code, and as you’re not sending code to users, not an issue (your JavaScript will still be visible).

There’s nothing really wrong with copying the source code separately to your target computer, and the Julia runtime. You just want to make sure your Julia packages are also installed there.

If the installation/dependencies are a problem, you could also use a container. I.e. LXC (LXD?) on Linux. That would also get you something to move between (Linux) computers, and should just work, and wouldn’t need compiling. I’m not up to speed on if works on Windows, Docker there instead?