How to input files as command line arguments to compiled Julia

You might want to try ] dev MyTestPkg in your default environment. That will make using MyTestPkg work there.

1 Like

Thank you, I added the recommendesd info to my Project.toml file.

I now get this error:

(MyTestPkg) pkg> st
     Project MyTestPkg v0.1.0
      Status `~/connor/juliaRppgPacakge/.julia/dev/MyTestPkg/Project.toml`
  [336ed68f] CSV v0.8.5
  [a93c6f00] DataFrames v1.2.0
  [9b87118b] PackageCompiler v1.2.7
  [44cfe95a] Pkg

julia> using MyTestPkg
ERROR: ArgumentError: Package MyTestPkg [7b6ef1f2-e27a-4927-afbe-f37c5d2ce363] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

II ran Pkg.instantiate() and nothing changed.

This is the full Project.toml file:

name = "MyTestPkg"
uuid = "7b6ef1f2-e27a-4927-afbe-f37c5d2ce363"
authors = ["connor and contributors"]
version = "0.1.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

The ] dev MyTestPkg step was meant for your default environment not the MyTestPkg environment. For the MyTestPkg environment, just do ] rm MyTestPkg to remove the confusion.

I’m confused about your setup. What is the output of Base.load_path() ?

1 Like

With @mkitti we now have two paths to follow. I am not sure if dev will help, but you should try and report the outcome, just to be sure.

So, I don’t know exactly how this uuid needs to be.
So, at this point, and we have moved quite away from the original problem, I would suggest, that we just start from the beginning.
If you agree, start a new REPL.
Do the following steps again (and nothing else), I will do the same. I have installed 1.6.2 for this:

(@v1.6) pkg> add PkgTemplates

julia> using PkgTemplates

julia> t = Template(;user="oheil")

julia> t("MyNewTestPkg")

Of course with your personal information.

The last command gives the following output for me:

julia> t("MyNewTestPkg")
[ Info: Running prehooks
[ Info: Running hooks
  Activating environment at `C:\Users\Oli\.julia\dev\MyNewTestPkg\Project.toml`
    Updating registry at `C:\Users\Oli\.julia\registries\General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
  No Changes to `C:\Users\Oli\.julia\dev\MyNewTestPkg\Project.toml`
  No Changes to `C:\Users\Oli\.julia\dev\MyNewTestPkg\Manifest.toml`
Precompiling project...
  1 dependency successfully precompiled in 0 seconds
  Activating environment at `C:\Users\Oli\.julia\environments\v1.6\Project.toml`
[ Info: Running posthooks
[ Info: New package is at C:\Users\Oli\.julia\dev\MyNewTestPkg

The created C:\Users\Oli\.julia\dev\MyNewTestPkg\Project.toml is:

name = "MyNewTestPkg"
uuid = "b0b1eab8-5069-44c2-ab62-22553fc0f810"
authors = ["oheil <XXX@XXX.XX> and contributors"]
version = "0.1.0"

[compat]
julia = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

How is yours?

1 Like

Thanks so much. I completed all the steps you suggested.

(@v1.6) pkg> add PkgTemplates
    Updating registry at `~/.julia/registries/General`
using PkgTemplates   Resolving package versions...
  No Changes to `~/.julia/environments/v1.6/Project.toml`
  No Changes to `~/.julia/environments/v1.6/Manifest.toml`

julia> using PkgTemplates

julia> t = Template(;user="connormeaton")
julia> t("MyNewTestPkg")
[ Info: Running prehooks
[ Info: Running hooks
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml`
    Updating registry at `~/.julia/registries/General`
  No Changes to `~/.julia/dev/MyNewTestPkg/Project.toml`
  No Changes to `~/.julia/dev/MyNewTestPkg/Manifest.toml`
Precompiling project...
  1 dependency successfully precompiled in 1 seconds
  Activating environment at `~/.julia/environments/v1.6/Project.toml`
[ Info: Running posthooks
[ Info: New package is at /Users/connor/.julia/dev/MyNewTestPkg

Here is my Project.toml file:

name = "MyNewTestPkg"
uuid = "2140c8d5-dde9-453d-9c68-b5c56000c311"
authors = ["Connor Eaton <XXX@XXX.XX> and contributors"]
version = "0.1.0"

[compat]
julia = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

I also have done this, how does this look?

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml`

(MyNewTestPkg) pkg> st
     Project MyNewTestPkg v0.1.0
      Status `~/.julia/dev/MyNewTestPkg/Project.toml` (empty project)

So far looks perfect.
Now the next two steps, either in a new REPL or the still open one if you have.
These are mine:

julia> pwd()
"C:\\Users\\Oli"

(@v1.6) pkg> activate .julia\\dev\\MyNewTestPkg
  Activating environment at `C:\Users\Oli\.julia\dev\MyNewTestPkg\Project.toml`

julia> using MyNewTestPkg

These are yours:

...

great you have done already.
Looks good.
Can you now do

julia> using MyNewTestPkg
1 Like

I’m with you.

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml`

julia> using MyNewTestPkg

I think we are good now.
Ok, after activating the environment with

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml

you can now add the dependencies with

(MyNewTestPkg) pkg> add DataFrames, CSV
1 Like

Great, I added.

Now with ] st

(MyNewTestPkg) pkg> st
     Project MyNewTestPkg v0.1.0
      Status `~/.julia/dev/MyNewTestPkg/Project.toml`
  [336ed68f] CSV v0.8.5
  [a93c6f00] DataFrames v1.2.0

If have done this too, and I had to restart the REPL (output told me so). After restart do again:

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml

(MyNewTestPkg) pkg> add DataFrames, CSV
1 Like

Than edit the src file MyNewTestPkg.jl which is already created and add your code. It is:

module MyNewTestPkg

using DataFrames, CSV

function julia_main()
    try
        real_main()
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

function real_main()
    for arg in ARGS
        println(arg)
    end
    println("it worked!")

    df = CSV.read(string(ARGS[1]), DataFrame);
    println(df)

    return
end

if abspath(PROGRAM_FILE) == @__FILE__
    real_main()
end

end
1 Like

When this is done, I assume a fresh REPL, you do:

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml`

(MyNewTestPkg) pkg> add PackageCompiler

julia> using PackageCompiler

julia> cd("/Users/connor/.julia/dev/MyNewTestPkg")

julia> using MyNewTestPkg
[ Info: Precompiling MyNewTestPkg [b0b1eab8-5069-44c2-ab62-22553fc0f810]

julia> create_app("../MyNewTestPkg", "MyNewTestPkgApp";force=true)

The cd command is only that the App build folder is created in the project folder. Just a matter of taste.

The command using MyNewTestPkg does a precompile, don’t know if it’s needed, but it doesn’t harm.

I am getting the working app with that and hope, that you will do now, too.
(I am off to bed now, until tomorrow).

1 Like

Almost there…

julia> create_app("../MyNewTestPkg", "MyNewTestPkgApp";force=true)
 Downloading artifact: i868-w64-mingw32
┌ Error: Tree Hash Mismatch!
│   Expected git-tree-sha1:   <replacing this random string with text in case its sensitive>
│   Calculated git-tree-sha1: <replacing this random string with text in case its sensitive>
└ @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pk  Downloaded artifact: i868-w64-mingw32
 Downloading artifact: i868-w64-mingw32
┌ Error: Tree Hash Mismatch!
│   Expected git-tree-sha1:   <replacing this random string with text in case its sensitive>
│   Calculated git-tree-sha1: <replacing this random string with text in case its sensitive>
└ @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pk  Downloaded artifact: i868-w64-mingw32
ERROR: Unable to automatically install 'i868-w64-mingw32' from '/Users/connor/.julia/packages/PackageCompiler/BjVzm/Artifacts.toml'
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] ensure_artifact_installed(name::String, meta::Dict{String, Any}, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, verbose::Bool, quiet_download::Bool, io::Base.TTY)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:445
 [3] ensure_artifact_installed(name::String, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, pkg_uuid::Nothing, verbose::Bool, quiet_download::Bool, io::Base.TTY)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:408
 [4] ensure_artifact_installed(name::String, artifacts_toml::String)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:403
 [5] bundle_artifacts(ctx::Pkg.Types.Context, app_dir::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/BjVzm/src/PackageCompiler.jl:780
 [6] create_app(package_dir::String, app_dir::String; app_name::Nothing, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, audit::Bool, force::Bool, c_driver_program::String, cpu_target::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/BjVzm/src/PackageCompiler.jl:666
 [7] top-level scope
   @ REPL[18]:1

This is … mildly… frustrating…
I have no idea why this happens now, perhaps @mkitti ?

1 Like

The 32 bit mingw compiler was recently added: Add 32 bit Windows gcc artifact by davidanthoff · Pull Request #516 · JuliaLang/PackageCompiler.jl · GitHub. I am not sure why it would fail the tree hash check. cc @davidanthoff

1 Like

Thanks @oheil @mkitti @kristoffer.carlsson . The help I received thus far has been tremendous! Regarding this error, in case more detail is helpful:

I’m on a Mac Catalina10.15.6
I installed julia via homebrew
This is a totally fresh install of julia.

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4* (2021-07-14 15:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

To work around the problem, you should be able to remove PackageCompiler from your MyNewTestPkgApp project. It is enough to have it installed in your global environment (v1.6).

1 Like

To be explicit, you may try:

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating environment at `~/.julia/dev/MyNewTestPkg/Project.toml`

(MyNewTestPkg) pkg> rm PackageCompiler

julia> using PackageCompiler

julia> cd("/Users/connor/.julia/dev/MyNewTestPkg")

julia> create_app("../MyNewTestPkg", "MyNewTestPkgApp";force=true)
1 Like

Thank you @oheil @kristoffer.carlsson

It looks like I never had PackageCompiler installed in the project?

(@v1.6) pkg> activate /Users/connor/.julia/dev/MyNewTestPkg
  Activating new environment at `/Users/connor/.julia/dev/MyNewTestPkg/Project.toml`

(MyNewTestPkg) pkg> rm PackageCompiler
ERROR: The following package names could not be resolved:
 * PackageCompiler (not found in project or manifest)


julia> using PackageCompiler

julia> pwd()
"/Users/connor/.julia/dev/MyNewTestPkg"

julia> create_app("../MyNewTestPkg", "MyNewTestPkgApp";force=true)
 Downloading artifact: i868-w64-mingw32
┌ Error: Tree Hash Mismatch!
│   Expected git-tree-sha1:   <replacing this random string with text in case its sensitive>
│   Calculated git-tree-sha1: <replacing this random string with text in case its sensitive>
└ @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pk  Downloaded artifact: i868-w64-mingw32
 Downloading artifact: i868-w64-mingw32
┌ Error: Tree Hash Mismatch!
│   Expected git-tree-sha1:   <replacing this random string with text in case its sensitive>
│   Calculated git-tree-sha1: <replacing this random string with text in case its sensitive>
└ @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pk  Downloaded artifact: i868-w64-mingw32
ERROR: Unable to automatically install 'i868-w64-mingw32' from '/Users/connor/.julia/packages/PackageCompiler/BjVzm/Artifacts.toml'
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] ensure_artifact_installed(name::String, meta::Dict{String, Any}, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, verbose::Bool, quiet_download::Bool, io::Base.TTY)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:445
 [3] ensure_artifact_installed(name::String, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, pkg_uuid::Nothing, verbose::Bool, quiet_download::Bool, io::Base.TTY)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:408
 [4] ensure_artifact_installed(name::String, artifacts_toml::String)
   @ Pkg.Artifacts /private/tmp/julia-20210715-9083-1kg5j1n/julia-1.6.2/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:403
 [5] bundle_artifacts(ctx::Pkg.Types.Context, app_dir::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/BjVzm/src/PackageCompiler.jl:780
 [6] create_app(package_dir::String, app_dir::String; app_name::Nothing, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, audit::Bool, force::Bool, c_driver_program::String, cpu_target::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/BjVzm/src/PackageCompiler.jl:666
 [7] top-level scope
   @ REPL[35]:1