zhiburt / tabled

An easy to use library for pretty print tables of Rust structs and enums.
MIT License
2.01k stars 84 forks source link

Why is the unicode-width dep pinned to version 0.11.1? #423

Open discosultan opened 2 months ago

discosultan commented 2 months ago

https://github.com/zhiburt/tabled/blob/300c07bd53c945671e8115811c1689cb1353feff/papergrid/Cargo.toml#L16

russellbanks commented 2 months ago

This is what I could find: https://github.com/zhiburt/tabled/pull/415#issuecomment-2231893362.

However this means that you can't use tabled if you have dependencies that also use unicode-width, like ratatui:

error: failed to select a version for `unicode-width`.                                                                                                                                                                                                                                                             
    ... required by package `papergrid v0.12.0`
    ... which satisfies dependency `papergrid = "^0.12"` of package `tabled v0.16.0`
    ... which satisfies dependency `tabled = "^0.16.0"`
versions that meet the requirements `=0.1.11` are: 0.1.11

all possible versions conflict with previously selected packages.

  previously selected package `unicode-width v0.1.13`
    ... which satisfies dependency `unicode-width = "^0.1.13"` of package `ratatui v0.28.0`
    ... which satisfies dependency `ratatui = "^0.28.0"`
discosultan commented 2 months ago

Ran into the same issue in combination with ratatui :)

zhiburt commented 2 months ago

Good question

Ahhhh I was not expecting such outcomes

I guess you better stick with v0.14 then till it's resolved?

The thought about this bound was that they had changed the logic of calculations. So important assumption that width(char) == width(string(char)) no longer true (maybe it was a wrong assumption to begin with). Because of this some emojie and complex UTF8 symbols was incorrectly rendered.

So I decided to make this bound. But maybe it shall be investigated (the logic changed accordingly) to be removed.

zhiburt commented 2 months ago

@discosultan @russellbanks

I had to mention that you can do it by changes in Cargo.toml

tabled = "=0.14" # or whatever version you were bound to

Sorry for ping; just wanna make sure it's resolved on your end.

Have a great weekend.

discosultan commented 2 months ago

Thanks for the follow-up. That's the workaround I went with.

Enjoy the weekend.

joshtriplett commented 2 months ago

I ran into this as well, and it's likewise blocking me from upgrading tabled.

pipelight commented 1 month ago

From what I understand.

Char/String width computation has changed recently in the unicode-width crate.

Exceptions can be found here: https://github.com/unicode-rs/unicode-width/blob/master/tests/tests.rs

Upgrading papergrid to the latest unicode-width version will need to replace single character-based width methods (now unusable anymore) by string width methods.

Looking at the inner functionning, this involves some big changes in the crate logic.

zhiburt commented 1 month ago

Upgrading papergrid to the latest unicode-width version will need to replace single character-based width methods (now unusable anymore) by string width methods.

Exactly.

But I kind of hesitant of it. I mean personally it's hard to even comprehend what's the source of truth. In a sense that we must not never calculate chars width or what. That's something I must figured out.

Looking at the inner functionning, this involves some big changes in the crate logic.

Hopefully not BIG but yes...

sunshowers commented 1 month ago

FWIW https://github.com/unicode-rs/unicode-width/issues/66 suggests that the unicode-width changes have been reverted in 0.1.14, and the behavior changes are now in 0.2.0.

sunshowers commented 1 month ago

Ah, sorry -- only the newline change has been reverted. The emoji width changes are still present, so they'd have to be worked around. (And yeah, I guess strings would have to be considered holistically).

joshka commented 1 month ago

This is what I could find: #415 (comment).

However this means that you can't use tabled if you have dependencies that also use unicode-width, like ratatui:

error: failed to select a version for `unicode-width`.                                                                                                                                                                                                                                                             
    ... required by package `papergrid v0.12.0`
    ... which satisfies dependency `papergrid = "^0.12"` of package `tabled v0.16.0`
    ... which satisfies dependency `tabled = "^0.16.0"`
versions that meet the requirements `=0.1.11` are: 0.1.11

all possible versions conflict with previously selected packages.

  previously selected package `unicode-width v0.1.13`
    ... which satisfies dependency `unicode-width = "^0.1.13"` of package `ratatui v0.28.0`
    ... which satisfies dependency `ratatui = "^0.28.0"`

We're discussing what to do with Ratatui in https://github.com/ratatui/ratatui/issues/1271 Our current thinking is that we should go to 0.2.0 and pin at a specific patch version. If we do that this will fix this problem (as it's possible to have two different minor versions in the same dependency tree, just not patch versions). That is at least until this crate moves on to 0.2.0, from which point the multiple pinned patch versions issue will be a potential problem again.

zhiburt commented 1 month ago

@joshka maybe we just shall remove this bound here and have some issues with UTF8 :sweat_smile: , until I figure something out. Hope to tackle it this weekend.

joshtriplett commented 1 week ago

I think this issue can now be closed.