Cannot use serve --open with --port 0
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 22.2k
- Forks
- 1.9k
- PR merge metrics
- PR metrics pending
Description
Problem
When using the mdbook serve command with --port 0 and --open options, the opened page is wrong, as the port is 0 instead of the random port attributed by the system.
Steps
mdbook init abc --forcemdbook serve abc --port 0 --open
Possible Solution(s)
The serving_url should contain the bound port instead of the asked port (0)
Maybe using something like bind_ephemeral could be used. It would maybe require to move the creation of the warp server in a separate function run before the thread spawn.
Notes
No response
Version
mdbook v0.4.47
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/cmd/serve.rs around lines 88-92 and trace how the Warp server is created, spawned, and used to build serving_url. Investigate bind_ephemeral as suggested, then verify that mdbook serve abc --port 0 --open opens the randomly assigned bound port rather than port 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100