BinaryBuilder.jl
BinaryBuilder.jl copied to clipboard
Better error message for installing package on unsupported platform
When the build_tarballs.jl
has proper platforms
configured (see https://github.com/JuliaPackaging/Yggdrasil/blob/0432ac88f57b4309b1bc98b075443fd39a89446a/X/Xyce/build_tarballs.jl#L40) and someone tries to install a package on an unsupported platform the current error message is something like:
(Simulation) pkg> add Xyce
Updating registry at `C:\Users\foo\.julia\registries\General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Resolving package versions...
Updating `C:\Users\foo\OneDrive\Documents\Github\MeLPUF\Simulation\Project.toml`
[1b67bd2a] ~ Xyce v0.1.0 `https://github.com/JuliaComputing/Xyce.jl#main` ⇒ v0.1.0
Updating `C:\Users\foo\OneDrive\Documents\Github\MeLPUF\Simulation\Manifest.toml`
[1b67bd2a] ~ Xyce v0.1.0 `https://github.com/JuliaComputing/Xyce.jl#main` ⇒ v0.1.0
Precompiling project...
✗ Xyce
0 dependencies successfully precompiled in 4 seconds (17 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
julia> import Pkg; Pkg.precompile()
Precompiling project...
✗ Xyce
0 dependencies successfully precompiled in 3 seconds (17 already precompiled)
ERROR: The following 1 direct dependency failed to precompile:
Xyce [1b67bd2a-23ea-4736-a23a-3ec91cbf2075]
ERROR: LoadError: UndefVarError: xycelib not defined
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base .\Base.jl:26
And a long stacktrace. It would be better to have an error message to say the platform is unsupported.
This is tricky, because we want to allow installing JLL packages on all platforms, mainly because Pkg.jl has no notion of optional packages, so we can't really make them error out on some platforms.
However, what you can do is to add an __init__
function to Xyce.jl
which does something like this:
__init__() = Xyce_jll.is_available || @warn "The Xyce library is not available for your platform"