Failure to compile to .exe "LoadError: ArgumentError: Package Base does not have Decimals in its dependencies:"

I’m an apprentice for development working with C# and a few months ago I have been playing around with basics of Julia whenever I have some free time. I am still learning. I decided to start a small project calculating the average grade after receiving grades in school subjects. My problem is, I can’t compile it to an .exe and I am out of options. :frowning: The links lead you to the screenshots for the following details.

This is my script:

My code
using Decimals
module CalculateAverageGrade
    function _calculateAverageGrade()
        list = Array{Int}(undef,11);
        for i in 1:length(list)
            saveInput::String = "";
            validInput::Bool = false;
            while(!validInput)
                saveInput = strip(readline())
                try
                    if isempty(saveInput) || !isinteger(parse(Int8, saveInput)) || parse(Int8, saveInput) <= 0 || parse(Int8, saveInput) > 6
                        println("Fehlerhafte Eingabe. Wiederhole deine Eingabe:")
                        continue
                    else
                        validInput = true;
                    end 
                catch e
                    println("Fehlerhafte Eingabe. Wiederhole deine Eingabe:")
                    continue
                end           
            end
            grade::Int8 = parse(Int8, saveInput);
            list[i] = grade;
        end
        averageGrade = decimal(sum(list) / length(list))
        println("Dein Notendurchschnitt ist: $averageGrade")
        readline()
        clear()
    end

    function julia_main()
        _calculateAverageGrade()
    end
end

You are free to give me feedbacks how to improve the code.

From what I have learned, in order to compile a project to an .exe, the .jl file needs to be in /<Projectname>/src/. In /src needs to be the desired .jl file with the same name as the main project folder.

Images

https://abload.de/img/untitled-290doj.jpg

In the REPL, I change the directory to \julia\CalculateAverageGrade, then ], activate ., add PackageCompiler and then I get the following output:

1st Output

https://abload.de/img/untitled-3bles9.jpg

With import Pkg; Pkg.precompile() I get the following:

2nd Output

And finally…

julia> create_app("CalculateAverageGrade.jl", "_Compiled")
ERROR: could not find project at "CalculateAverageGrade.jl"

although I confirmed with pwd() I am in the project folder.

The REPL said I should use Pkg.resolve() or Pkg.instantiate() but this didn’t solve anything.

Probably you should move using Decimals inside the module (see Loading package outside of main module when precompiling could have better error message · Issue #45832 · JuliaLang/julia · GitHub).

Thanks for the reply. I put using Decimals below module.
However, I still get this message

ERROR: LoadError: ArgumentError: Package CalculateAverageGrade does not have Pkg in its dependencies:

I went back to REPL and executed using Pkg; Pkg.add("Decimals") to no avail. I get the same suggestions executing Pkg.instantiate() and Pkg.resolve() and the latter results to No changes to [...] in the REPL.

Did you activate your package’s environment before adding the dependency?

Thank you. That did the trick.
In the REPL:

]
activate .
(MyPackage) pkg> add <NameOfPackage>

In this case “” was “Decimals”.
Then I copied the contents of Manifest.toml into the same named file in my project folder. Lastly, I copied over the line Decimals = "<UUID>" from Project.toml to the same named file in my project folder.
Compiling my project was a success.

Edit: Forgot to mention that the error message should give the suggestion to add the necessary package with the aformentioned steps if it wasn’t done previously.