ratatui / ansi-to-tui

Convert ansi colored text to tui::text::Text
https://crates.io/crates/ansi-to-tui
MIT License
57 stars 21 forks source link

Semver hazard due to `>=` in ratatui dependency #32

Open willcrichton opened 1 year ago

willcrichton commented 1 year ago

Hi, I ran into a semver hazard with this library. I depend on ratatui 0.21. I did cargo update and my library broke because ansi-to-tui 3.1 depends on ratatui 0.22. In general, I believe that using >= is considered an anti-pattern as per the Cargo book:

The resolver algorithm may converge on a solution that includes two copies of a dependency when one would suffice. For example:

  # Package A
  [dependencies]
  rand = "0.7"

  # Package B
  [dependencies]
  rand = ">=0.6"  # note: open requirements such as this are discouraged

In this example, Cargo may build two copies of the rand crate, even though a single copy at version 0.7.3 would meet all requirements. This is because the resolver’s algorithm favors building the latest available version of rand for Package B, which is 0.8.5 at the time of this writing, and that is incompatible with Package A’s specification. The resolver’s algorithm does not currently attempt to “deduplicate” in this situation.

The use of open-ended version requirements like >=0.6 is discouraged in Cargo.

I suppose one fix would be to publish a different version of ansi-to-tui for each 0.x release of ratatui. I'm not sure if there's a better solution.

uttarayan21 commented 1 year ago

Initially I was using ratatui = 0.* as a dependency but since they introduced a breaking change on 0.21 that no longer worked. Maybe I should make a deprecated feature that'd replace the Line the with the older Spans and bump the major version. Do you think that's a better solution ?

willcrichton commented 1 year ago

I see. It's fine to require that ratatui should actually be 0.22 if they introduced a breaking change. I wouldn't use >= 0.21 as the requirement then, and just specify a dependency on 0.22.

uttarayan21 commented 8 months ago

From next release onwards I'll match a major version of this crate to a minor version of ratatui until it reaches 1.0 stable