ratatui: Examples use unreleased code incompatible with 0.25.0
Note: this is a pinned post for visibility
Summary
We write code on the main branch, and update the examples to align with that code. This will become a future release (usually around 6-8 weeks between releases). When we implement new code or change behavior, sometime that code will be incompatible with the current release. The examples then don’t always compile with the current release.
Workarounds
There are a few ways to work around this problem:
- view the version of the examples aligns with the version of Ratatui that you’re using. E.g. https://github.com/ratatui-org/ratatui/tree/v0.25.0/examples
- compile the examples with a local version of the source code rather than the released version
- update to the latest -alpha release which is generally released weekly on Saturdays. E.g. https://crates.io/crates/ratatui/0.26.0-alpha.1
- To work out whether the code is a breaking change, see the BREAKING-CHANGES doc.
Details
In #773 we discovered that changing the examples in the main branch can be confusing when the code in the example doesn’t match the latest released docs / libraries.
@Libroru wrote:
I updated the tabs.rs example to use the new syntax for tabs. Other examples might need to be changed as well.
@kdheepak wrote:
This PR changes it from the new to the old syntax. Can you clarify where you read about this? If anything has to be changed to the new syntax, it is probably our documentation on the website.
@joshka wrote:
Ah, that would make sense. I didn’t think about how this sort of thing would affect users when updating the examples. Oops.
@libroru wrote:
That’s how I got it working in my personal projects with version
0.25.0
. But yeah in addition to that the documentation also shows the old syntax. I figured that that would be the new syntax since it worked on a local installation of0.25.0
.
@Valentin271 wrote:
Links to github should also point to the released tag, not main. Otherwise the links always points to unreleased items.
Probably same for the website?
Edit: That would mean rigth now the doc should point to 0.26 … Or the next alpha version. That’s kind of hard to maintain …
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 17 (11 by maintainers)
How about we see whether the examples readme fix helps for a little while and go from there. I’m guessing that this should fix most of the problem, but we can also prioritize which option to try next if it doesn’t.
I prefer users to see the latest available version of the code. Not the version released with the release.
Kinda - I’ve done quite a few tui to ratatui migrations in various projects to check out how much breakage there really is. For the most part it’s
Spans -> Line
,Frame<B>
->Frame
, and adding a check for KeyKind::Pressed on the crossterm event handler.I’d say it’s more move fast and break things with caution.
It seems like a lot of work to set this up (and then to maintain / make it work with the automatic previews / etc.), when the workaround is:
git checkout v0.25.0; bat examples/tabs.rs
I’d lean towards not making that tradeoff.
The solution I proposed would link them to the one which was released together with the documentation. So, if they’re reading the most recent documentation, they’ll be linked to the most recently released version.
The question is, I think, whether a quick fix which helps now, and can be reverted later, is something you’re willing to apply.
While I’m an outsider, I’m not sure point releases would be healthy at this point in the project’s life. You’re moving fast and breaking things a lot. Simply own it and tell people. Put a giant warning at the front of your page “Ratatui is moving fast and breaking things”.
Thinking further, yes, I think that’s it - it’s a mismatch between people’s expectation and the actual lifetime stage of Ratatui. You’re still early, iterating on the API design, moving fast and breaking things. People treat the project like it was a stable library.
I’m suggesting just moving all examples we have one level down, so the examples folder has a
README.md
and just one folder. And keep everything else about our workflow the same. I called the foldernightly
but very open to alternate names.I don’t like different branches as well just because when you make a PR on github it makes it to the default branch of the repo. The only solution that kind of works here is making
develop
the default branch and merge / squash tomain
only when making a release. Because what I’ve found is that when see the default branch isdevelop
, then know they have to switch tomain
when they want to look at examples.to be clear, I’m certainly not suggesting we use a
develop
branch. If nothing else, I like the simplicity of just one branchmain
and the git history of it, and I’m up to try a number of different approaches before I could even consider adevelop
branch approach. My point is simply that this is a UX problem, and we can try to improve the flow in a number of different ways.Currently, my understand is that users open GitHub, click on the examples folder, and open whatever sounds interesting to them. The README on GitHub is below our long list of example files. If they are then interested in running it, they create a new project, add ratatui, copy paste the example and it breaks.
This is largely a GitHub UX problem imo. If for example GitHub allowed us to make a tag the default landing page, we wouldn’t run into this issue. Or if we changed our workflow to
develop
andmain
was always just the latest releases, this would solve our problem. I suspect just seeing adevelop
branch when they land on GitHub will hint to users what is happening when their code fails to compile.I have a simpler idea that we can try. Currently we have:
I propose we have
This way clicking on the examples folder will result in the README being prominently displayed.
i.e. we don’t have any files except the readme at the folder level of the examples.
The README can even be the same readme but click to the latest tagged release.