I replaced the include with the code, as you suggested. The first error message was exactly as before:
pkg> add Distributions.jl
Updating registry at `C:\Users\fsald\.julia\registries\General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
No Changes to `C:\Dropbox\Code\Julia\bootstrapwalkforward\BW\Project.toml`
No Changes to `C:\Dropbox\Code\Julia\bootstrapwalkforward\BW\Manifest.toml`
Precompiling project...
✗ BW
0 dependencies successfully precompiled in 22 seconds (210 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
Then I ran
import Pkg
Pkg.precompile()
and VSCode froze. I restarted VSCode and got this message:
Session contents restored from 12/13/2021 at 7:36:07 AM
ERROR: LoadError: IOError: connect: no such file or directory (ENOENT)
Stacktrace:
[1] wait_connected(x::Base.PipeEndpoint)
@ Sockets C:\Users\fsald\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\Sockets.jl:532
[2] connect
@ C:\Users\fsald\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\Sockets.jl:567 [inlined]
[3] connect
@ C:\Users\fsald\AppData\Local\Programs\Julia-1.7.0\share\julia\stdlib\v1.7\Sockets\src\PipeServer.jl:97 [inlined]
[4] serve(args::String; is_dev::Bool, crashreporting_pipename::String)
@ VSCodeServer c:\Users\fsald\.vscode\extensions\julialang.language-julia-1.5.6\scripts\packages\VSCodeServer\src\VSCodeServer.jl:100
[5] top-level scope
@ c:\Users\fsald\.vscode\extensions\julialang.language-julia-1.5.6\scripts\terminalserver\terminalserver.jl:45
in expression starting at c:\Users\fsald\.vscode\extensions\julialang.language-julia-1.5.6\scripts\terminalserver\terminalserver.jl:24
julia>
I will rewrite the tr_sign functions as you suggested. One of them is passed to a struct that is an argument of a function, so I like having nice names for them. Could pass a lambda as an argument instead but that would obscure the code.
In any case, I tried completely eliminating all three functions from the code and passing
x -> max.(sign.(t), 0)
to the struct. Restarted VSCode, tried again add Distributions.jl and got the same message.
Giving up on import Pkg I used the ] key and tried precompile. Got this message:
(BW) pkg> precompile
Precompiling project...
✗ BW
0 dependencies successfully precompiled in 18 seconds (210 already precompiled)
ERROR: The following 1 direct dependency failed to precompile:
BW [23dbc89a-8e17-4d23-a4a2-f1aee6f5fec8]
Failed to precompile BW [23dbc89a-8e17-4d23-a4a2-f1aee6f5fec8] to C:\Users\fsald\.julia\compiled\v1.7\BW\jl_3392.tmp.
┌ Warning: Package Base does not have Dates in its dependencies:
│ - If you have Base 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 Base
└ Loading Dates into Base from project dependency, future warnings for Base are suppressed.
ERROR: LoadError: UndefVarError: include not defined
Stacktrace:
[1] top-level scope
@ c:\Dropbox\Code\Julia\bootstrapwalkforward\BW\src\BW.jl:57
[2] include
@ .\Base.jl:418 [inlined]
[3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1318
[4] top-level scope
@ none:1
[5] eval
@ .\boot.jl:373 [inlined]
[6] eval(x::Expr)
@ Base.MainInclude .\client.jl:453
[7] top-level scope
@ none:1
in expression starting at c:\Dropbox\Code\Julia\bootstrapwalkforward\BW\src\BW.jl:57
Now the problem is in line 57 of BW.jl, which is another include statement.
So it looks like the problem is really with include statements. I guess if I inlined all the included code and eliminated all include statements I could get BW.jl to precompile.
The warning message about package Base not having Dates among its dependencies is also mysterious.
Oddly, the code runs despite all of the above.