Skip to content

Example only compiles with stored Cargo.lock #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eburdette0 opened this issue Jul 24, 2023 · 4 comments
Open

Example only compiles with stored Cargo.lock #3

eburdette0 opened this issue Jul 24, 2023 · 4 comments

Comments

@eburdette0
Copy link

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
Copy link
Member

AaronErhardt commented Jul 24, 2023

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
Copy link
Contributor

sdroege commented Aug 7, 2023

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
Copy link
Author

"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
Copy link
Contributor

sdroege commented Aug 8, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants