GiovineItalia / Compose.jl

Declarative vector graphics
http://giovineitalia.github.io/Compose.jl/latest/
Other
248 stars 81 forks source link

Precompilation causes Compose to not notice if Cairo is later installed #139

Closed jwmerrill closed 6 years ago

jwmerrill commented 9 years ago

I installed Gadfly, used it once, and then installed Cairo so that I could draw to PNGs. Even after I installed Cairo, I was getting:

julia> using Gadfly

julia> PNG("myplot.png", 12cm, 6cm)
ERROR: Cairo must be installed to use the PNG backend.
 in PNG at /Users/jwm/.julia/v0.4/Compose/src/Compose.jl:137

I was able to fix this problem by removing all the cache files in ~/.julia/lib/v0.4/ and then running using Gadfly again, which recompiled everything.

dcjones commented 9 years ago

Particularly with precompilation, there's no good way to handle optional dependencies in julia packages. It's a major deficiency, but one that will be fixed eventually. Until then, I don't think there's is much I can do about this except tell people to delete their Gadfly.ji.

jwmerrill commented 9 years ago

It's safer to tell people to delete everything in the cache. I initially tried just deleting Gadfly.ji, but that doesn't clear Compose.ji, and ends up leaving things in an inconsistent state.

dcjones commented 9 years ago

Ok, there's at least a warning now.

timholy commented 9 years ago

I suspect that things get a lot more robust if you put if ... && __precompile__() at the top of each module that Gadfly uses.

dcjones commented 9 years ago

Would that help with optional dependencies? Cairo already has a __precompile__().

timholy commented 9 years ago

More likely the "inconsistent state," which I'm guessing must be something like https://github.com/dcjones/Gadfly.jl/pull/667#issuecomment-133991074. Optional dependencies probably wouldn't be detect unless it has to recompile Gadfly/Compose itself. (By deleting Compose.ji, though, it should have triggered a recompile of both Compose and Gadfly.)

brian-j-smith commented 9 years ago

What do you make of this Cairo must be installed error occurring on the julialang.org package tests but not on Travis?

This is happening too for my Mamba package, which uses Gadfly. Adding an explicit using Cairo before using Gadfly to my package does not seem to help. Testing on my local machines is fine, so I'm at a loss for how to fix the julialang.org failure. Any help with that would be greatly appreciated. Thanks!

timholy commented 9 years ago

Huh, looks like we missed the __precompile__ at the top of Compose. Kinda ironic, since I got all of its dependencies. Want to submit a PR, @brian-j-smith?

brian-j-smith commented 9 years ago

Eureka! Mystery solved... will gladly submit a PR.

bjarthur commented 6 years ago

We now do conditional loading of the Cairo code with #282. There are still some issues but those are tracked by #299