plotters-rs / plotters-gtk-demo

Minimal example for GTK + Plotters
18 stars 3 forks source link

Example only compiles with stored Cargo.lock #3

Open eburdette0 opened 1 year ago

eburdette0 commented 1 year ago

When I clone and run the example, it compiles and works, really cool!

If I move all the code to a new project with the same sources and Cargo.toml, the build generates an error at line 62 in src/gaussian_plot/imp.rs: expected cairo::context::Context, found gtk4::cairo::Context

It looks like this might be similar to this stackoverflow issue which was solved by resolving the dependency conflict between versions of cairo-rs in gtk4 and plotters-cairo: https://stackoverflow.com/questions/75229974/how-do-i-fix-my-compatability-errors-when-using-plotterscairobackend-with-gtk

I get very similar compiler notes after the error, with two versions of cairo-rs showing up.

What is an appropriate resolution for this? To specify versions of gtk, plotters and plotters-cairo in the repository's .toml file?

AaronErhardt commented 1 year ago

I think the versions should be compatible. This repo uses gtk4-rs 0.6 which depends on cairo-rs 0.17 which is the same version that the plotters-cairo backend uses.

@sdroege do you have an idea why this is happening?

Also, I think we should update to gtk4-rs 0.7 and cairo-rs 0.18 soon anyway, but I don't know if that solves the problem.

sdroege commented 1 year ago

The versions need to be in sync, yes. How can I reproduce the problem reported here?

Updating to the latest versions should also happen but I'm quite busy right now so if someone else has time to look into that...

eburdette0 commented 1 year ago

"How can I reproduce the problem reported here?" Sorry I wasn't explicit:

I get a different error now (see below), but the procedure is the same: 1) clone plotters-gtk-demo 2) cargo run -> no error

3) delete cargo.lock 4) cargo run -> error

error[E0277]: the trait bound `CairoBackend<'_>: plotters::prelude::DrawingBackend` is not satisfied
  --> src/gaussian_plot/imp.rs:63:23
   |
63 |         self.plot_pdf(backend).unwrap();
   |              -------- ^^^^^^^ the trait `plotters::prelude::DrawingBackend` is not implemented for `CairoBackend<'_>`
   |              |
   |              required by a bound introduced by this call

It works if I: repeat 1,2,3) 5) Comment out #git = "https://github.com/plotters-rs/plotters" 6) add version = "0.3.5"

(I repeated this with a clean repo clone for sanity)

Can either of you reproduce that? Maybe it's my error.

.
. There seem to be a large number of changes if I diff cargo.lock. I can dump the different iterations somewhere if that will help

One thing looked strange during the failed run- there are two (different?) compiled versions of plotters-backend listed if that's relevant " Compiling plotters-backend v0.3.5 Compiling plotters-backend v0.3.5 (https://github.com/plotters-rs/plotters#7030c735) "

sdroege commented 1 year ago

Yes there was an API change in plotters and different versions of the crate are pulled in currently. That would have to be fixed. I don't know what the plan here is. plotters, plotters-cairo and this all have to point to consistent versions of everything. Something for @AaronErhardt to decide (e.g. should everything always point to git of plotters related crates? latest releases?)

I also get this error but that's different from the original error you reported though (expected cairo::context::Context, found gtk4::cairo::Context).