Skip to content

appender: gate symlink support to platforms that support it#3568

Open
ameyypawar wants to merge 1 commit into
tokio-rs:mainfrom
ameyypawar:fix/3536-appender-wasm-symlink
Open

appender: gate symlink support to platforms that support it#3568
ameyypawar wants to merge 1 commit into
tokio-rs:mainfrom
ameyypawar:fix/3536-appender-wasm-symlink

Conversation

@ameyypawar

Copy link
Copy Markdown

Motivation

tracing-appender 0.2.5 added the latest_symlink builder option (#3447), which
depends on the symlink crate. That crate
only defines symlink_file and remove_symlink_file on unix, windows, and
redox, so on other targets — notably wasm32-unknown-unknown — the appender no
longer compiles:

error[E0425]: cannot find function `remove_symlink_file` in crate `symlink`
   --> tracing-appender/src/rolling.rs:804:26
    |
804 |         let _ = symlink::remove_symlink_file(&symlink_path);
    |                          ^^^^^^^^^^^^^^^^^^^ not found in `symlink`
note: found an item that was configured out
    |
133 | #[cfg(any(target_os = "redox", unix, windows))]

tracing-appender 0.2.4 built fine on wasm32; 0.2.5 regressed.

Fixes: #3536

Solution

Gate the symlink dependency to the platforms that support symbolic links, and
gate the code that uses it the same way:

  • In Cargo.toml, move symlink into
    [target.'cfg(any(unix, windows, target_os = "redox"))'.dependencies].
  • In rolling.rs, extract the symlink logic from create_writer into an
    update_latest_symlink helper with two cfg-gated definitions: the real one
    for symlink-capable targets, and a no-op for the rest. test_latest_symlink
    is gated the same way.

On platforms without symbolic-link support, latest_symlink is now a no-op (the
log file is still written; no symlink is created), and the crate compiles again.
The existing test-build-wasm CI job builds tracing-appender for wasm32.

…#3536)

`tracing-appender` 0.2.5 added the `latest_symlink` builder option, which
depends on the `symlink` crate. That crate only defines `symlink_file` and
`remove_symlink_file` on `unix`, `windows`, and `redox`, so the appender no
longer compiles on targets such as `wasm32-unknown-unknown`:

    error[E0425]: cannot find function `remove_symlink_file` in crate `symlink`

Gate the `symlink` dependency and the code that uses it to those targets. On
platforms without symbolic-link support, `latest_symlink` becomes a no-op (the
log file is still written; no symlink is created), and the crate compiles
again.

Fixes: tokio-rs#3536
@ameyypawar ameyypawar requested review from a team, hawkw and hds as code owners June 23, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tracing-appender no longuer compile for wasm target

1 participant