Skip to content
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

trying to use tui-textarea in another project - version conflict #55

Closed
pm100 opened this issue Nov 22, 2023 · 13 comments
Closed

trying to use tui-textarea in another project - version conflict #55

pm100 opened this issue Nov 22, 2023 · 13 comments
Labels
invalid This doesn't seem right

Comments

@pm100
Copy link
Contributor

pm100 commented Nov 22, 2023

I am trying to make gitui use tui-textarea (its why I came here in the first place)

My problem is that I need to use the same version of ratatui in gitui and tta. This because arguments from ratatui (Style) are passed between the gitui code and the code I have written using tta.

gitui says

ratatui = { version = "0.23", default-features = false, features = ['crossterm', 'serde'] }

(It used to say 0.21 but I changed it in my PR to I am putting together). I cannot change gitui to 0.24 because there are breaking changes between 0.23 and 0.24. I need both to use 0.23

tta says

ratatui = { version = ">=0.23.0 , <1", default-features = false, optional = true }

If I build that I end up with gitui using 0.23 and tta using 0.24, does not compile

You would think that cargo would work this out ,but it doesnt.

The only way I have found to make that work is by changing ttas cargo.toml to specifically say

ratatui = { version = "0.23.0", default-features = false, optional = true }

this then works, but seems like a backwards step (that I would have to persuade you to make, which seems wrong anyway)

Any advice ?

@rhysd
Copy link
Owner

rhysd commented Nov 22, 2023

Please paste entire error message. I see no conflict. >=0.23.0 means 0.23 or later. So 0.24 should be allowed.

And cargo update may resolve the issue if your local lock file is outdated.

@joshka
Copy link
Contributor

joshka commented Nov 22, 2023

How about we bump gitui to 0.24 instead? I'll slap a PR for it together.

@joshka
Copy link
Contributor

joshka commented Nov 22, 2023

extrawurst/gitui#1959

@pm100
Copy link
Contributor Author

pm100 commented Nov 22, 2023

@joshka - it doubt it will be accepted soon. I have worked with gitui for 3 years, owner has very aggressive cargo check deny policy of duplicated crates etc. There is another issue blocking a ton of stuff for months extrawurst/gitui#1781 (I have a PR that been sitting there for 5 months).

This is a classic example of whats wrong with cargo version management, its almost perfect, but not quite, and its hard to override (patch does not help here)

@pm100
Copy link
Contributor Author

pm100 commented Nov 22, 2023

here you see the clash because my file textinput.rs receives Style arguments from gitui and passes the to tta

   Compiling gitui v0.24.3 (C:\work\git4\gitui)
error[E0308]: mismatched types
    --> src\components\textinput.rs:211:28
     |
211  |                 .set_cursor_line_style(self.theme.text(true, false));
     |                  --------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ratatui::style::Style`, found a different `ratatui::style::Style`
     |                  |
     |                  arguments to this method are incorrect
     |
     = note: `ratatui::style::Style` and `ratatui::style::Style` have similar names, but are actually distinct types
note: `ratatui::style::Style` is defined in crate `ratatui`
    --> C:\Users\paulm\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ratatui-0.23.0\src\style.rs:253:1
     |
253  | pub struct Style {
     | ^^^^^^^^^^^^^^^^
note: `ratatui::style::Style` is defined in crate `ratatui`
    --> C:\Users\paulm\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ratatui-0.24.0\src\style.rs:192:1
     |
192  | pub struct Style {
     | ^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `ratatui` are being used?
note: method defined here
    --> C:\Users\paulm\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tui-textarea-0.3.1\src\textarea.rs:1203:12
     |
1203 |     pub fn set_cursor_line_style(&mut self, style: Style) {
     |            ^^^^^^^^^^^^^^^^^^^^^

@joshka
Copy link
Contributor

joshka commented Nov 23, 2023

I know that the bitflags change is problematic - it will change the serialization format, which will mean that configuration breaks for every user.

@pm100
Copy link
Contributor Author

pm100 commented Nov 23, 2023

Extrawurst already has that fixed in a branch. I raised it when I first was trying to get tta into gitui. This is a long saga . See extrawurst/gitui#1929

@rhysd
Copy link
Owner

rhysd commented Nov 24, 2023

here you see the clash because my file textinput.rs receives Style arguments from gitui and passes the to tta

Isn't it your local problem with old Cargo.lock file? If not, I think you need to understand what crate requires ratatui 0.24 and what crate requires 0.23.

@rhysd
Copy link
Owner

rhysd commented Nov 24, 2023

I confirmed ratatui 0.23 worked with tui-textarea fine. cargo test passed and cargo run --example editor worked. If it's not your local problem, I guess some other crate in your dependencies requires 0.24 or later.

> cargo tree --edges no-dev
tui-textarea v0.4.0
├── crossterm v0.27.0
│   ├── bitflags v2.4.1
│   ├── crossterm_winapi v0.9.1
│   │   └── winapi v0.3.9
│   ├── parking_lot v0.12.1
│   │   ├── lock_api v0.4.11
│   │   │   └── scopeguard v1.2.0
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.1.0
│   │   └── parking_lot_core v0.9.9
│   │       ├── cfg-if v1.0.0
│   │       ├── smallvec v1.11.2
│   │       └── windows-targets v0.48.5
│   │           └── windows_x86_64_msvc v0.48.5
│   └── winapi v0.3.9
├── ratatui v0.23.0
│   ├── bitflags v2.4.1
│   ├── cassowary v0.3.0
│   ├── crossterm v0.27.0 (*)
│   ├── indoc v2.0.4 (proc-macro)
│   ├── itertools v0.11.0
│   │   └── either v1.9.0
│   ├── paste v1.0.14 (proc-macro)
│   ├── strum v0.25.0
│   │   └── strum_macros v0.25.3 (proc-macro)
│   │       ├── heck v0.4.1
│   │       ├── proc-macro2 v1.0.69
│   │       │   └── unicode-ident v1.0.12
│   │       ├── quote v1.0.33
│   │       │   └── proc-macro2 v1.0.69 (*)
│   │       ├── rustversion v1.0.14 (proc-macro)
│   │       └── syn v2.0.39
│   │           ├── proc-macro2 v1.0.69 (*)
│   │           ├── quote v1.0.33 (*)
│   │           └── unicode-ident v1.0.12
│   ├── unicode-segmentation v1.10.1
│   └── unicode-width v0.1.11
└── unicode-width v0.1.11

@rhysd
Copy link
Owner

rhysd commented Nov 24, 2023

I created a dummy project to confirm this is not a problem of tui-textarea. The configuration was:

[dependencies]
ratatui = { version = "0.23", default-features = false, features = ['crossterm', 'serde'] }
tui-textarea = "0.4.0"

and I checked the dependencies tree. ratatui v0.23.0 was correctly shared between the dummy project and tui-textarea:

> cargo tree
test_project v0.1.0
├── ratatui v0.23.0
│   ├── bitflags v2.4.1
│   │   └── serde v1.0.193
│   │       └── serde_derive v1.0.193 (proc-macro)
│   │           │   └── unicode-ident v1.0.12
│   │           ├── quote v1.0.33
│   │           │   └── proc-macro2 v1.0.69 (*)
│   │           └── syn v2.0.39
│   │               ├── proc-macro2 v1.0.69 (*)
│   │               ├── quote v1.0.33 (*)
│   │               └── unicode-ident v1.0.12
│   ├── cassowary v0.3.0
│   ├── crossterm v0.27.0
│   │   ├── bitflags v2.4.1 (*)
│   │   ├── crossterm_winapi v0.9.1
│   │   │   └── winapi v0.3.9
│   │   ├── parking_lot v0.12.1
│   │   │   ├── lock_api v0.4.11
│   │   │   │   └── scopeguard v1.2.0
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.1.0
│   │   │   └── parking_lot_core v0.9.9
│   │   │       ├── cfg-if v1.0.0
│   │   │       ├── smallvec v1.11.2
│   │   │       └── windows-targets v0.48.5
│   │   │           └── windows_x86_64_msvc v0.48.5
│   │   └── winapi v0.3.9
│   ├── indoc v2.0.4 (proc-macro)
│   ├── itertools v0.11.0
│   │   └── either v1.9.0
│   ├── paste v1.0.14 (proc-macro)
│   ├── serde v1.0.193 (*)
│   ├── strum v0.25.0
│   │   └── strum_macros v0.25.3 (proc-macro)
│   │       ├── heck v0.4.1
│   │       ├── proc-macro2 v1.0.69 (*)
│   │       ├── quote v1.0.33 (*)
│   │       ├── rustversion v1.0.14 (proc-macro)
│   │       └── syn v2.0.39 (*)
│   ├── unicode-segmentation v1.10.1
│   └── unicode-width v0.1.11
└── tui-textarea v0.4.0
    ├── crossterm v0.27.0 (*)
    ├── ratatui v0.23.0 (*)
    └── unicode-width v0.1.11

@rhysd rhysd closed this as completed Nov 24, 2023
@rhysd rhysd added the invalid This doesn't seem right label Nov 24, 2023
@pm100
Copy link
Contributor Author

pm100 commented Nov 26, 2023

@rhysd - ty for looking at this. I was not very clear. I know how to make this work by hand editing the cargo.lock file, works perfectly, and is not a problem with tui-textarea. But I doubt owner will accept that.

You have experience with complex version juggling (tui, ratatui, crossterm....) and wondered if you had any tricks that I could use. Seems not

@pacak
Copy link

pacak commented Jan 11, 2024

I created a dummy project to confirm this is not a problem of tui-textarea. The configuration was:

FWIW I created the same project just now

[package]
name = "foo2"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ratatui = { version = "0.23", default-features = false, features = ['crossterm', 'serde'] }
tui-textarea = "0.4.0"

And the tree looks like this:

foo2 v0.1.0 (/path/to/project)
├── ratatui v0.23.0
│   ├── bitflags v2.4.1
│   │   └── serde v1.0.195
│   │       └── serde_derive v1.0.195 (proc-macro)
│   │           ├── proc-macro2 v1.0.76
│   │           │   └── unicode-ident v1.0.12
│   │           ├── quote v1.0.35
│   │           │   └── proc-macro2 v1.0.76 (*)
│   │           └── syn v2.0.48
│   │               ├── proc-macro2 v1.0.76 (*)
│   │               ├── quote v1.0.35 (*)
│   │               └── unicode-ident v1.0.12
│   ├── cassowary v0.3.0
│   ├── crossterm v0.27.0
│   │   ├── bitflags v2.4.1 (*)
│   │   ├── libc v0.2.152
│   │   ├── mio v0.8.10
│   │   │   ├── libc v0.2.152
│   │   │   └── log v0.4.20
│   │   ├── parking_lot v0.12.1
│   │   │   ├── lock_api v0.4.11
│   │   │   │   └── scopeguard v1.2.0
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.1.0
│   │   │   └── parking_lot_core v0.9.9
│   │   │       ├── cfg-if v1.0.0
│   │   │       ├── libc v0.2.152
│   │   │       └── smallvec v1.11.2
│   │   ├── signal-hook v0.3.17
│   │   │   ├── libc v0.2.152
│   │   │   └── signal-hook-registry v1.4.1
│   │   │       └── libc v0.2.152
│   │   └── signal-hook-mio v0.2.3
│   │       ├── libc v0.2.152
│   │       ├── mio v0.8.10 (*)
│   │       └── signal-hook v0.3.17 (*)
│   ├── indoc v2.0.4 (proc-macro)
│   ├── itertools v0.11.0
│   │   └── either v1.9.0
│   ├── paste v1.0.14 (proc-macro)
│   ├── serde v1.0.195 (*)
│   ├── strum v0.25.0
│   │   └── strum_macros v0.25.3 (proc-macro)
│   │       ├── heck v0.4.1
│   │       ├── proc-macro2 v1.0.76 (*)
│   │       ├── quote v1.0.35 (*)
│   │       ├── rustversion v1.0.14 (proc-macro)
│   │       └── syn v2.0.48 (*)
│   ├── unicode-segmentation v1.10.1
│   └── unicode-width v0.1.11
└── tui-textarea v0.4.0
    ├── crossterm v0.27.0 (*)
    ├── ratatui v0.25.0
    │   ├── bitflags v2.4.1 (*)
    │   ├── cassowary v0.3.0
    │   ├── crossterm v0.27.0 (*)
    │   ├── indoc v2.0.4 (proc-macro)
    │   ├── itertools v0.12.0
    │   │   └── either v1.9.0
    │   ├── lru v0.12.1
    │   │   └── hashbrown v0.14.3
    │   │       ├── ahash v0.8.7
    │   │       │   ├── cfg-if v1.0.0
    │   │       │   ├── once_cell v1.19.0
    │   │       │   └── zerocopy v0.7.32
    │   │       │   [build-dependencies]
    │   │       │   └── version_check v0.9.4
    │   │       └── allocator-api2 v0.2.16
    │   ├── paste v1.0.14 (proc-macro)
    │   ├── stability v0.1.1 (proc-macro)
    │   │   ├── quote v1.0.35 (*)
    │   │   └── syn v1.0.109
    │   │       ├── proc-macro2 v1.0.76 (*)
    │   │       ├── quote v1.0.35 (*)
    │   │       └── unicode-ident v1.0.12
    │   ├── strum v0.25.0 (*)
    │   ├── unicode-segmentation v1.10.1
    │   └── unicode-width v0.1.11
    └── unicode-width v0.1.11

foo2 pulls in ratatui 0.23 as expected, tta pulls in 0.25 as the most recent available version.

I can make it behave in two different ways. Adding tta into a project with already existing ratatui makes it so tta uses it - I'm assuming you used cargo add if it was a new project, adding it to a project at the same time as ratatui or simply not having the lock file - pulls in two different versions and causes problems.

@Gnurfos
Copy link

Gnurfos commented Jan 29, 2024

Hi,

This issue, combined with cargo's rust-lang/cargo#9029 is forcing us to commit Cargo.lock in all of our libraries, even the ones higher up the tree (which don't depend on tui things directly), which is not a place where we want to be.

It looks like the fix/change on cargo side will take a long time at best. Is there any chance you'd reconsider expressing your dependency in a more classical way ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

5 participants