Install mdserve from cargo
Install mdserve from cargo
I'll help you install mdserve from cargo. Let me do that for you.
{
"command": "cargo install mdserve",
"description": "Install mdserve from cargo",
"timeout": 300000
}Updating crates.io index
Installing mdserve v0.4.1
Updating crates.io index
Locking 136 packages to latest compatible versions
Adding axum v0.7.9 (available: v0.8.6)
Compiling proc...Updating crates.io index
Installing mdserve v0.4.1
Updating crates.io index
Locking 136 packages to latest compatible versions
Adding axum v0.7.9 (available: v0.8.6)
Compiling proc-macro2 v1.0.101
Compiling unicode-ident v1.0.19
Compiling quote v1.0.41
Compiling libc v0.2.177
Compiling bytes v1.10.1
Compiling itoa v1.0.15
Compiling pin-project-lite v0.2.16
Compiling futures-core v0.3.31
Compiling fnv v1.0.7
Compiling version_check v0.9.5
Compiling typenum v1.19.0
Compiling zerocopy v0.8.27
Compiling cfg-if v1.0.4
Compiling pin-utils v0.1.0
Compiling log v0.4.28
Compiling httparse v1.10.1
Compiling serde_core v1.0.228
Compiling generic-array v0.14.9
Compiling futures-sink v0.3.31
Compiling slab v0.4.11
Compiling futures-task v0.3.31
Compiling http v1.3.1
Compiling once_cell v1.21.3
Compiling tracing-core v0.1.34
Compiling tower-service v0.3.3
Compiling thiserror v1.0.69
Compiling http-body v1.0.1
Compiling tracing v0.1.41
Compiling rustversion v1.0.22
Compiling tower-layer v0.3.3
Compiling mime v0.3.17
Compiling unicase v2.8.1
Compiling percent-encoding v2.3.2
Compiling httpdate v1.0.3
Compiling serde v1.0.228
Compiling utf8parse v0.2.2
Compiling anstyle-parse v0.2.7
Compiling mime_guess v2.0.5
Compiling block-buffer v0.10.4
Compiling crypto-common v0.1.6
Compiling digest v0.10.7
Compiling syn v2.0.106
Compiling http-body-util v0.1.3
Compiling futures-channel v0.3.31
Compiling smallvec v1.15.1
Compiling anstyle-query v1.1.4
Compiling utf-8 v0.7.6
Compiling is_terminal_polyfill v1.70.1
Compiling atomic-waker v1.1.2
Compiling serde_json v1.0.145
Compiling byteorder v1.5.0
Compiling sync_wrapper v1.0.2
Compiling anstyle v1.0.13
Compiling socket2 v0.6.1
Compiling mio v1.0.4
Compiling getrandom v0.2.16
Compiling cpufeatures v0.2.17
Compiling ryu v1.0.20
Compiling rand_core v0.6.4
Compiling sha1 v0.10.6
Compiling colorchoice v1.0.4
Compiling data-encoding v2.9.0
Compiling anstream v0.6.21
Compiling form_urlencoded v1.2.2
Compiling strsim v0.11.1
Compiling anyhow v1.0.100
Compiling heck v0.5.0
Compiling memchr v2.7.6
Compiling clap_lex v0.7.6
Compiling same-file v1.0.6
Compiling bitflags v2.9.4
Compiling walkdir v2.5.0
Compiling clap_builder v4.5.49
Compiling fsevent-sys v4.1.0
Compiling base64 v0.22.1
Compiling http-range-header v0.4.2
Compiling unicode-id v0.3.6
Compiling matchit v0.7.3
Compiling notify-types v2.0.0
Compiling notify v8.2.0
Compiling markdown v1.0.0
Compiling ppv-lite86 v0.2.21
Compiling rand_chacha v0.3.1
Compiling rand v0.8.5
Compiling tokio-macros v2.6.0
Compiling futures-macro v0.3.31
Compiling thiserror-impl v1.0.69
Compiling serde_derive v1.0.228
Compiling async-trait v0.1.89
Compiling serde_path_to_error v0.1.20
Compiling tokio v1.48.0
Compiling futures-util v0.3.31
Compiling clap_derive v4.5.49
Compiling tungstenite v0.24.0
Compiling clap v4.5.49
Compiling axum-core v0.4.5
Compiling serde_urlencoded v0.7.1
Compiling hyper v1.7.0
Compiling tokio-util v0.7.16
Compiling tower v0.5.2
Compiling tokio-tungstenite v0.24.0
Compiling tower-http v0.6.6
Compiling hyper-util v0.1.17
Compiling axum v0.7.9
Compiling mdserve v0.4.1
error[E0658]: `let` expressions in this position are unstable
--> /Users/idvorkin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/mdserve-0.4.1/src/app.rs:421:16
|
421 | if let Ok(json) = serde_json::to_string(&reload_msg)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
For more information about this error, try `rustc --explain E0658`.
error: could not compile `mdserve` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `mdserve v0.4.1`, intermediate artifacts can be found at `/var/folders/2m/01w6lsn93dn4pylxkjkydg140000gn/T/cargo-installKjoNah`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Igor, the installation of mdserve from cargo failed because it's incompatible with the current Rust compiler version. The error shows that mdserve v0.4.1 uses unstable Rust features (let expressions in certain positions) that aren't available in the stable Rust compiler.
Here are your options:
Use a nightly Rust compiler (if you have rustup installed):
cargo +nightly install mdserve
Install an alternative markdown server - there are other tools that work with stable Rust:
miniserve - a popular file server that handles markdownsimple-http-server - another reliable alternativeWould you like me to install one of these alternatives instead?
Use a different markdown preview tool - if you just need to preview markdown files, there are other options like:
just jekyll-serve)What would you like me to do?
Create a new `GitHub` issue.
I'll create a new GitHub issue for you. Let me do that now.
{
"command": "gh issue create --title \"mdserve cargo installation fails on stable Rust\" --body \"$(cat <<'EOF'\n## Problem\n\nInstalling `mdserve` fro...{
"command": "gh issue create --title \"mdserve cargo installation fails on stable Rust\" --body \"$(cat <<'EOF'\n## Problem\n\nInstalling `mdserve` from cargo fails with a compilation error on stable Rust:\n\n```\nerror[E0658]: `let` expressions in this position are unstable\n --> /Users/idvorkin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/mdserve-0.4.1/src/app.rs:421:16\n |\n421 | if let Ok(json) = serde_json::to_string(&reload_msg)\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n```\n\n## Details\n\n- Package: `mdserve v0.4.1`\n- Issue: Uses unstable Rust features that aren't available in stable compiler\n- Command attempted: `cargo install mdserve`\n\n## Possible Solutions\n\n1. Use nightly Rust: `cargo +nightly install mdserve`\n2. Use alternative markdown servers:\n - `miniserve`\n - `simple-http-server`\n3. Use existing Jekyll setup for markdown preview\n\n## Decision Needed\n\nDo we want to:\n- Add mdserve to our tooling and document the nightly requirement?\n- Choose a different markdown server that works with stable Rust?\n- Stick with Jekyll for all markdown previewing?\n\nEOF\n)\"",
"description": "Create GitHub issue about mdserve installation"
}
https://github.com/idvorkin/idvorkin.github.io/issues/195
Done! I've created issue #195 documenting the mdserve installation problem: https://github.com/idvorkin/idvorkin.github.io/issues/195
The issue captures the compilation error, the root cause (unstable Rust features), and outlines possible solutions for you to decide on.
Open in mdtoc repo
{
"command": "open https://github.com/idvorkin/idvorkin.github.io/issues/195",
"description": "Open issue #195 in browser"
}The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the us...
The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to tell you how to proceed.
Close this issue. And reporn in it on mdserver repo
I'll close this issue and reopen it in the mdserve repo instead.
{
"command": "gh issue close 195 --comment \"Closing - this should be reported upstream in the mdserve repository instead.\"",
"description": "Close is...{
"command": "gh issue close 195 --comment \"Closing - this should be reported upstream in the mdserve repository instead.\"",
"description": "Close issue #195"
}
{
"command": "gh search repos mdserve --limit 5",
"description": "Search for mdserve repository"
}â Closed issue idvorkin/idvorkin.github.io#195 (mdserve cargo installation fails on stable Rust)
midoks/mdserver-web Simple Linux Panel public 2025-10-14T10:37:50Z jfernandez/mdserve Fast markdown preview server with live reload and theme support. public 2025-10-14T12:23:20Z midoks/mdserver-mac m...
midoks/mdserver-web Simple Linux Panel public 2025-10-14T10:37:50Z jfernandez/mdserve Fast markdown preview server with live reload and theme support. public 2025-10-14T12:23:20Z midoks/mdserver-mac mdserver (mac version, secondary development) public 2025-09-08T15:02:44Z midoks/MDserver_64 PHP integrated environment - (Win7, 8, 10) 64-bit available public 2024-11-27T04:35:06Z zhiyelee/mdserver Static http server with markdown supported public 2024-10-16T03:51:56Z
Perfect! I found the mdserve repo. It's jfernandez/mdserve. Now let me create an issue there:
{
"command": "gh issue create --repo jfernandez/mdserve --title \"cargo install mdserve fails on stable Rust - uses unstable let expressions\" --body \"$(cat <<...{
"command": "gh issue create --repo jfernandez/mdserve --title \"cargo install mdserve fails on stable Rust - uses unstable let expressions\" --body \"$(cat <<'EOF'\n## Problem\n\nInstalling `mdserve v0.4.1` from cargo fails with a compilation error on stable Rust:\n\n```\nerror[E0658]: `let` expressions in this position are unstable\n --> /Users/idvorkin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/mdserve-0.4.1/src/app.rs:421:16\n |\n421 | if let Ok(json) = serde_json::to_string(&reload_msg)\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information\n```\n\n## Environment\n\n- Package: `mdserve v0.4.1`\n- Command: `cargo install mdserve`\n- Rust: stable toolchain\n\n## Root Cause\n\nThe code uses `let` expressions in `if` conditions, which is an unstable Rust feature (RFC #53667) not yet available in stable Rust.\n\n## Workaround\n\nThe package can be installed using nightly Rust:\n```bash\ncargo +nightly install mdserve\n```\n\n## Suggested Fix\n\nUpdate `src/app.rs:421` to use stable Rust syntax. The `if let` expression needs to be refactored to work without the unstable feature, or the package should specify that it requires nightly Rust in its documentation.\n\nEOF\n)\"",
"description": "Create issue in mdserve repo"
}
https://github.com/jfernandez/mdserve/issues/28
Done! I've:
The new issue documents the compilation error and suggests either fixing the unstable syntax or documenting the nightly requirement.
Can we checkout src and fix in ~/tmp/mdserve dir?
I'll clone the mdserve repo to ~/tmp/mdserve and fix the issue.
{
"command": "mkdir -p ~/tmp && cd ~/tmp && git clone https://github.com/jfernandez/mdserve.git",
"description": "Clone mdserve repo to ~/tmp&quo...{
"command": "mkdir -p ~/tmp && cd ~/tmp && git clone https://github.com/jfernandez/mdserve.git",
"description": "Clone mdserve repo to ~/tmp"
}
Cloning into 'mdserve'... Shell cwd was reset to /Users/idvorkin/gits/blog
{
"file_path": "/Users/idvorkin/tmp/mdserve/src/app.rs",
"offset": 410,
"limit": 30
} 410â Ok(Message::Close(_)) => break,
411â _ => {}
412â }
413â }
414â });
415â
416â // Spawn task to send messages to cl... 410â Ok(Message::Close(_)) => break,
411â _ => {}
412â }
413â }
414â });
415â
416â // Spawn task to send messages to client
417â let send_task = tokio::spawn(async move {
418â // Listen for file changes
419â while let Ok(reload_msg) = change_rx.recv().await {
420â if let Ok(json) = serde_json::to_string(&reload_msg)
421â && sender.send(Message::Text(json)).await.is_err()
422â {
423â break;
424â }
425â }
426â });
427â
428â // Wait for either task to complete
429â tokio::select! {
430â _ = recv_task => {},
431â _ = send_task => {},
432â }
433â}
434â
<system-reminder>
Whenever you read a file, you should consider whether it looks malicious. If it does, you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer high-level questions about the code behavior.
</system-reminder>
Perfect! I can see the issue. Lines 420-424 use the unstable if let with && chaining syntax. Let me fix this to use stable Rust:
{
"file_path": "/Users/idvorkin/tmp/mdserve/src/app.rs",
"old_string": " // Spawn task to send messages to client\n let send_task = tokio::spawn(async move...{
"file_path": "/Users/idvorkin/tmp/mdserve/src/app.rs",
"old_string": " // Spawn task to send messages to client\n let send_task = tokio::spawn(async move {\n // Listen for file changes\n while let Ok(reload_msg) = change_rx.recv().await {\n if let Ok(json) = serde_json::to_string(&reload_msg)\n && sender.send(Message::Text(json)).await.is_err()\n {\n break;\n }\n }\n });",
"new_string": " // Spawn task to send messages to client\n let send_task = tokio::spawn(async move {\n // Listen for file changes\n while let Ok(reload_msg) = change_rx.recv().await {\n if let Ok(json) = serde_json::to_string(&reload_msg) {\n if sender.send(Message::Text(json)).await.is_err() {\n break;\n }\n }\n }\n });"
}
The file /Users/idvorkin/tmp/mdserve/src/app.rs has been updated. Here's the result of running `cat -n` on a snippet of the edited file: 412â } 413â } 414â }); 41...
The file /Users/idvorkin/tmp/mdserve/src/app.rs has been updated. Here's the result of running `cat -n` on a snippet of the edited file:
412â }
413â }
414â });
415â
416â // Spawn task to send messages to client
417â let send_task = tokio::spawn(async move {
418â // Listen for file changes
419â while let Ok(reload_msg) = change_rx.recv().await {
420â if let Ok(json) = serde_json::to_string(&reload_msg) {
421â if sender.send(Message::Text(json)).await.is_err() {
422â break;
423â }
424â }
425â }
426â });
427â
428â // Wait for either task to complete
429â tokio::select! {
430â _ = recv_task => {},
Great! Now let's test that it compiles with stable Rust:
{
"command": "cd ~/tmp/mdserve && cargo build",
"description": "Build mdserve with stable Rust",
"timeout": 300000
}Updating crates.io index Downloading crates ... Downloaded cfg-if v1.0.3 Downloaded clap v4.5.48 Downloaded clap_derive v4.5.47 Downloaded serde v1.0.226 Downloaded socket2 v0.6.0 Dow...
Updating crates.io index
Downloading crates ...
Downloaded cfg-if v1.0.3
Downloaded clap v4.5.48
Downloaded clap_derive v4.5.47
Downloaded serde v1.0.226
Downloaded socket2 v0.6.0
Downloaded serde_derive v1.0.226
Downloaded serde_core v1.0.226
Downloaded clap_builder v4.5.48
Downloaded libc v0.2.175
Downloaded tokio v1.47.1
Compiling proc-macro2 v1.0.101
Compiling unicode-ident v1.0.19
Compiling libc v0.2.175
Compiling bytes v1.10.1
Compiling itoa v1.0.15
Compiling pin-project-lite v0.2.16
Compiling futures-core v0.3.31
Compiling version_check v0.9.5
Compiling fnv v1.0.7
Compiling typenum v1.18.0
Compiling log v0.4.28
Compiling cfg-if v1.0.3
Compiling zerocopy v0.8.27
Compiling pin-utils v0.1.0
Compiling httparse v1.10.1
Compiling serde_core v1.0.226
Compiling futures-sink v0.3.31
Compiling futures-task v0.3.31
Compiling once_cell v1.21.3
Compiling generic-array v0.14.7
Compiling slab v0.4.11
Compiling tracing-core v0.1.34
Compiling tower-service v0.3.3
Compiling http v1.3.1
Compiling thiserror v1.0.69
Compiling tracing v0.1.41
Compiling http-body v1.0.1
Compiling utf8parse v0.2.2
Compiling unicase v2.8.1
Compiling rustversion v1.0.22
Compiling percent-encoding v2.3.2
Compiling tower-layer v0.3.3
Compiling httpdate v1.0.3
Compiling serde v1.0.226
Compiling mime v0.3.17
Compiling mime_guess v2.0.5
Compiling socket2 v0.6.0
Compiling mio v1.0.4
Compiling getrandom v0.2.16
Compiling ppv-lite86 v0.2.21
Compiling rand_core v0.6.4
Compiling cpufeatures v0.2.17
Compiling quote v1.0.40
Compiling rand_chacha v0.3.1
Compiling anstyle-parse v0.2.7
Compiling http-body-util v0.1.3
Compiling syn v2.0.106
Compiling crypto-common v0.1.6
Compiling block-buffer v0.10.4
Compiling rand v0.8.5
Compiling futures-channel v0.3.31
Compiling digest v0.10.7
Compiling atomic-waker v1.1.2
Compiling byteorder v1.5.0
Compiling sha1 v0.10.6
Compiling anstyle v1.0.11
Compiling data-encoding v2.9.0
Compiling smallvec v1.15.1
Compiling colorchoice v1.0.4
Compiling ryu v1.0.20
Compiling sync_wrapper v1.0.2
Compiling serde_json v1.0.145
Compiling anstyle-query v1.1.4
Compiling utf-8 v0.7.6
Compiling is_terminal_polyfill v1.70.1
Compiling anstream v0.6.20
Compiling form_urlencoded v1.2.2
Compiling memchr v2.7.5
Compiling clap_lex v0.7.5
Compiling strsim v0.11.1
Compiling bitflags v2.9.4
Compiling heck v0.5.0
Compiling same-file v1.0.6
Compiling anyhow v1.0.100
Compiling walkdir v2.5.0
Compiling clap_builder v4.5.48
Compiling fsevent-sys v4.1.0
Compiling base64 v0.22.1
Compiling matchit v0.7.3
Compiling http-range-header v0.4.2
Compiling unicode-id v0.3.6
Compiling notify-types v2.0.0
Compiling markdown v1.0.0
Compiling notify v8.2.0
Compiling serde_path_to_error v0.1.20
Compiling tokio-macros v2.5.0
Compiling futures-macro v0.3.31
Compiling thiserror-impl v1.0.69
Compiling serde_derive v1.0.226
Compiling async-trait v0.1.89
Compiling clap_derive v4.5.47
Compiling tokio v1.47.1
Compiling futures-util v0.3.31
Compiling clap v4.5.48
Compiling tungstenite v0.24.0
Compiling axum-core v0.4.5
Compiling serde_urlencoded v0.7.1
Compiling hyper v1.7.0
Compiling tower v0.5.2
Compiling tokio-util v0.7.16
Compiling tokio-tungstenite v0.24.0
Compiling tower-http v0.6.6
Compiling hyper-util v0.1.17
Compiling axum v0.7.9
Compiling mdserve v0.4.1 (/Users/idvorkin/tmp/mdserve)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 12.26s
Shell cwd was reset to /Users/idvorkin/gits/blog
Excellent! The build succeeded with stable Rust. The fix works perfectly. The issue was that the code was using the unstable if let ... && ... syntax, which I converted to nested if let statements that are stable Rust.
The fix changes:
if let Ok(json) = serde_json::to_string(&reload_msg)
&& sender.send(Message::Text(json)).await.is_err()
To:
if let Ok(json) = serde_json::to_string(&reload_msg) {
if sender.send(Message::Text(json)).await.is_err() {
This maintains the exact same logic but uses only stable Rust features. Would you like me to create a PR with this fix to submit to the mdserve repository?
Yup
I'll create a PR with this fix to the mdserve repository.
{
"command": "cd ~/tmp/mdserve && git checkout -b fix-stable-rust-compatibility",
"description": "Create new branch for fix"
}{
"command": "cd ~/tmp/mdserve && git add src/app.rs && git commit -m \"fix: use stable Rust syntax for conditional expression\n\nReplace unstable if-let-chain sy...{
"command": "cd ~/tmp/mdserve && git add src/app.rs && git commit -m \"fix: use stable Rust syntax for conditional expression\n\nReplace unstable if-let-chain syntax with nested if statements.\nThis allows mdserve to compile on stable Rust without requiring nightly.\n\nThe unstable syntax:\n if let Ok(json) = expr && condition { ... }\n\nIs replaced with stable equivalent:\n if let Ok(json) = expr {\n if condition { ... }\n }\n\nFixes #28\"",
"description": "Commit the fix"
}
Switched to a new branch 'fix-stable-rust-compatibility' Shell cwd was reset to /Users/idvorkin/gits/blog
[fix-stable-rust-compatibility 86b3256] fix: use stable Rust syntax for conditional expression 1 file changed, 4 insertions(+), 4 deletions(-) Shell cwd was reset to /Users/idvorkin/gits/blog
{
"command": "cd ~/tmp/mdserve && gh repo fork --remote=true",
"description": "Fork the mdserve repo"
}https://github.com/idvorkin/mdserve Shell cwd was reset to /Users/idvorkin/gits/blog
{
"command": "cd ~/tmp/mdserve && git push -u origin fix-stable-rust-compatibility",
"description": "Push branch to fork"
}branch 'fix-stable-rust-compatibility' set up to track 'origin/fix-stable-rust-compatibility'. remote: remote: Create a pull request for 'fix-stable-rust-compatibility' ...
branch 'fix-stable-rust-compatibility' set up to track 'origin/fix-stable-rust-compatibility'. remote: remote: Create a pull request for 'fix-stable-rust-compatibility' on GitHub by visiting: remote: https://github.com/idvorkin/mdserve/pull/new/fix-stable-rust-compatibility remote: To https://github.com/idvorkin/mdserve.git * [new branch] fix-stable-rust-compatibility -> fix-stable-rust-compatibility Shell cwd was reset to /Users/idvorkin/gits/blog
{
"command": "cd ~/tmp/mdserve && gh pr create --repo jfernandez/mdserve --title \"Fix: Enable compilation on stable Rust\" --body \"$(cat <<'EOF...{
"command": "cd ~/tmp/mdserve && gh pr create --repo jfernandez/mdserve --title \"Fix: Enable compilation on stable Rust\" --body \"$(cat <<'EOF'\n## Summary\n\nThis PR fixes the compilation error on stable Rust by replacing unstable `if-let-chain` syntax with nested `if` statements.\n\n## Problem\n\nThe current code uses an unstable Rust feature (if-let-chains, RFC #53667) that requires nightly Rust:\n\n```rust\nif let Ok(json) = serde_json::to_string(&reload_msg)\n && sender.send(Message::Text(json)).await.is_err()\n{\n break;\n}\n```\n\nThis causes a compilation error on stable Rust:\n```\nerror[E0658]: `let` expressions in this position are unstable\n```\n\n## Solution\n\nRefactor to use stable Rust syntax with nested if statements:\n\n```rust\nif let Ok(json) = serde_json::to_string(&reload_msg) {\n if sender.send(Message::Text(json)).await.is_err() {\n break;\n }\n}\n```\n\nThis maintains identical functionality while being compatible with stable Rust.\n\n## Testing\n\n- Built and compiled successfully on stable Rust toolchain\n- The logic flow remains exactly the same\n- No functional changes to the WebSocket handling behavior\n\nFixes #28\nEOF\n)\"",
"description": "Create PR to upstream repo"
}
https://github.com/jfernandez/mdserve/pull/29 Shell cwd was reset to /Users/idvorkin/gits/blog
Perfect! I've created PR #29 with the fix: https://github.com/jfernandez/mdserve/pull/29
The PR:
Once this is merged, cargo install mdserve will work on stable Rust without needing nightly.
Thnks can we install it
I'll install mdserve from your local fixed version.
{
"command": "cd ~/tmp/mdserve && cargo install --path .",
"description": "Install mdserve from local source",
"timeout": 300000
} Installing mdserve v0.4.1 (/Users/idvorkin/tmp/mdserve)
Updating crates.io index
Locking 136 packages to latest Rust 1.86.0 compatible versions
Adding axum v0.7.9 (available: v0.8.6)
... Installing mdserve v0.4.1 (/Users/idvorkin/tmp/mdserve)
Updating crates.io index
Locking 136 packages to latest Rust 1.86.0 compatible versions
Adding axum v0.7.9 (available: v0.8.6)
Compiling proc-macro2 v1.0.101
Compiling quote v1.0.41
Compiling unicode-ident v1.0.19
Compiling libc v0.2.177
Compiling itoa v1.0.15
Compiling bytes v1.10.1
Compiling pin-project-lite v0.2.16
Compiling futures-core v0.3.31
Compiling typenum v1.19.0
Compiling fnv v1.0.7
Compiling version_check v0.9.5
Compiling cfg-if v1.0.4
Compiling log v0.4.28
Compiling zerocopy v0.8.27
Compiling pin-utils v0.1.0
Compiling futures-sink v0.3.31
Compiling httparse v1.10.1
Compiling serde_core v1.0.228
Compiling once_cell v1.21.3
Compiling generic-array v0.14.9
Compiling futures-task v0.3.31
Compiling http v1.3.1
Compiling slab v0.4.11
Compiling tracing-core v0.1.34
Compiling http-body v1.0.1
Compiling thiserror v1.0.69
Compiling tower-service v0.3.3
Compiling tracing v0.1.41
Compiling utf8parse v0.2.2
Compiling tower-layer v0.3.3
Compiling percent-encoding v2.3.2
Compiling unicase v2.8.1
Compiling httpdate v1.0.3
Compiling rustversion v1.0.22
Compiling serde v1.0.228
Compiling mime v0.3.17
Compiling block-buffer v0.10.4
Compiling crypto-common v0.1.6
Compiling mime_guess v2.0.5
Compiling anstyle-parse v0.2.7
Compiling digest v0.10.7
Compiling http-body-util v0.1.3
Compiling futures-channel v0.3.31
Compiling smallvec v1.15.1
Compiling utf-8 v0.7.6
Compiling byteorder v1.5.0
Compiling data-encoding v2.9.0
Compiling syn v2.0.106
Compiling mio v1.0.4
Compiling socket2 v0.6.1
Compiling getrandom v0.2.16
Compiling cpufeatures v0.2.17
Compiling ryu v1.0.20
Compiling sha1 v0.10.6
Compiling rand_core v0.6.4
Compiling anstyle v1.0.13
Compiling colorchoice v1.0.4
Compiling is_terminal_polyfill v1.70.1
Compiling ppv-lite86 v0.2.21
Compiling sync_wrapper v1.0.2
Compiling serde_json v1.0.145
Compiling anstyle-query v1.1.4
Compiling atomic-waker v1.1.2
Compiling anstream v0.6.21
Compiling rand_chacha v0.3.1
Compiling rand v0.8.5
Compiling form_urlencoded v1.2.2
Compiling heck v0.5.0
Compiling anyhow v1.0.100
Compiling same-file v1.0.6
Compiling memchr v2.7.6
Compiling strsim v0.11.1
Compiling clap_lex v0.7.6
Compiling bitflags v2.9.4
Compiling clap_builder v4.5.49
Compiling serde_path_to_error v0.1.20
Compiling walkdir v2.5.0
Compiling fsevent-sys v4.1.0
Compiling notify-types v2.0.0
Compiling http-range-header v0.4.2
Compiling unicode-id v0.3.6
Compiling base64 v0.22.1
Compiling matchit v0.7.3
Compiling markdown v1.0.0
Compiling notify v8.2.0
Compiling tokio-macros v2.6.0
Compiling futures-macro v0.3.31
Compiling thiserror-impl v1.0.69
Compiling serde_derive v1.0.228
Compiling async-trait v0.1.89
Compiling clap_derive v4.5.49
Compiling tokio v1.48.0
Compiling futures-util v0.3.31
Compiling clap v4.5.49
Compiling tungstenite v0.24.0
Compiling serde_urlencoded v0.7.1
Compiling axum-core v0.4.5
Compiling hyper v1.7.0
Compiling tokio-tungstenite v0.24.0
Compiling tokio-util v0.7.16
Compiling tower v0.5.2
Compiling tower-http v0.6.6
Compiling hyper-util v0.1.17
Compiling axum v0.7.9
Compiling mdserve v0.4.1 (/Users/idvorkin/tmp/mdserve)
Finished `release` profile [optimized] target(s) in 23.23s
Installing /Users/idvorkin/.cargo/bin/mdserve
Installed package `mdserve v0.4.1 (/Users/idvorkin/tmp/mdserve)` (executable `mdserve`)
Shell cwd was reset to /Users/idvorkin/gits/blog
Perfect! mdserve v0.4.1 is now installed and ready to use. The fixed version compiled successfully on stable Rust and is now available in your ~/.cargo/bin/ directory.
You can now use mdserve <file.md> to serve markdown files with live reload support!
Can you explain the bug/issue and why diff fixes it?
I'll explain the bug and why the fix works.
The original code used this syntax:
if let Ok(json) = serde_json::to_string(&reload_msg)
&& sender.send(Message::Text(json)).await.is_err()
{
break;
}
This is called "if-let chains" - it combines a pattern match (if let) with a boolean condition (&&) in a single if statement.
This syntax is an unstable Rust feature (RFC #53667) that's only available in nightly Rust. It's not yet part of stable Rust because:
When you try to compile with stable Rust, the compiler sees this pattern and says "I don't recognize this syntax yet - you need nightly Rust to use it."
The fix converts the unstable if-let-chain into nested if statements using only stable features:
if let Ok(json) = serde_json::to_string(&reload_msg) {
if sender.send(Message::Text(json)).await.is_err() {
break;
}
}
This is functionally identical to the original:
First if let: Try to serialize reload_msg to JSON
json contains the string and we enter the blockSecond if: Try to send the message
send() returns an error (is_err() is true), we breaksend() succeeds, we continue the loopThe logic flow is exactly the same, but now it uses only stable Rust features that have been part of the language for years.
The if-let-chain syntax is more concise and reads more naturally for this "try this, and if it works, check that" pattern. But until it's stabilized, we need to use the nested approach for stable Rust compatibility.