Skip to content

[BUG] #244

@b9Joker108

Description

@b9Joker108

General Information
Version: current
Installation Method: git cloned locally and built
Operating System: amd64 Debian 12 'Bookworm'

I initially just tried: cargo install wiki-tui and there were all these errors. So, I resolved to build and compile the project from source.

Describe the bug

Problem 1: ratatui Version Mismatch

  • Symptom: The initial build failed with numerous mismatched types errors, involving ratatui::widgets::Block and ratatui::style::Style.
  • Cause: The project was using multiple versions of the ratatui crate due to its direct dependencies using one version and one of its indirect dependencies using an older version. This meant types with the same fully qualified name were actually different because they were from different crate versions.
  • Solution:
    1. Identify Problematic Dependency: The tui-logger crate, a dependency of the project was the culprit because it used an older version of ratatui.
    2. Explicitly set ratatui version: We updated the Cargo.toml file to explicitly specify a single, consistent version of ratatui (0.27.0 in this case) in the [dependencies] section:
      [dependencies]
      ratatui = "0.27.0"
      # ... other dependencies
    3. Clean the project: We ran cargo clean to remove old build artifacts and ensure that Cargo would resolve dependencies with the updated version.
    4. Rebuild: We used cargo build to compile the project with the single, specified version of ratatui.
    • Result: This resolved the type mismatches caused by having multiple versions of ratatui in our dependency tree.

Problem 2: Incorrect Usage of area.inner()

  • Symptom: A new build error arose after resolving the ratatui version mismatch, complaining about mismatched types between Margin and &Margin when using the area.inner() method.
  • Cause: The inner() method from ratatui expects a Margin struct to be passed by value, but the code was passing a reference (&Margin).
  • Solution:
    1. Locate the error: We used the compiler's error message to pinpoint the file src/components/page.rs at line 716 as the source of the error.
    2. Remove the &: We changed:
      area.inner(&Margin { ... });
      to:
      area.inner(Margin { ... });
    This passed the struct by value, as was expected by the function inner.
    • Result: This resolved the type mismatch, allowing the code to compile.

Problem 3: Deprecated Padding::zero() Usage

  • Symptom: A warning indicated that the Padding::zero() function was deprecated and recommended using the constant Padding::ZERO.
  • Cause: The code was using an old deprecated way of creating padding.
  • Solution:
    1. Locate the warning: We used the compiler warning message to pinpoint the file src/config.rs at line 478 as the source of the warning.
    2. Replace Padding::zero() with Padding::ZERO: We replaced
    padding: Padding::zero(),
    with:
    ```rust
    padding: Padding::ZERO,
    ```
    
    • Result: This resolved the warning and the code is using the modern and recommended API.

Final Result:

  • After implementing these steps, the wiki-tui project compiled successfully, without errors and with no warnings.
  • The project now uses a single, consistent version of ratatui.
  • The area.inner() and Padding methods are called correctly.

Expected behavior
I expected to be able to install the project with cargo in the first instance. In the second, I expected to be able to build the binary from source without a hitch. Please forgive me for not making a pull request with the changes, but I am very new to rust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugThis fixes a bug. Increment the minor version

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions