DioxusLabs / DioxusLabs/dioxus

Workspace dependency leads to `dx serve` hanging indefinetly

Open
#4,009 1 comment 0 reactions 0 assignees View on GitHub
bug cli
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

When running `dx serve` in a workspace where the frontend depends on the root package, the CLI hangs, doesn't output anything, and eats `Ctrl + c` and `Ctrl + z`.
Also, it doesn't correctly recognize all packages in the frontend.

**Steps To Reproduce**

Steps to reproduce the behavior:

- `cargo new --lib my-lib && cd my-lib`
- `dx new frontend`
- Add the snippets from below to the two `Cargo.toml` files
- `dx serve [-p frontend]` (in the workspace fails)
- `cd frontend && dx serve` hangs
- Commenting the workspace dependency out fixes the issue

```
# Cargo.toml
[workspace]
resolver = "2"
members = [".", "frontend"]

[workspace.dependencies]
my-lib = { path = "." }

# -- snip --
```

```
# frontend/Cargo.toml
# --snip --

[dependencies]
my-lib.workspace = true
dioxus = { version = "0.6.0", features = [] }

# -- snip --
```

**Expected behavior**

I would expect to be able to serve from the workspace root and the CLI to not hang

**Screenshots**

(works without the dep, but hangs with it)

https://github.com/user-attachments/assets/068b9378-a488-4ac2-af0c-a97516a03168

(does not list the `frontend` binary)
```
my-lib$ dx serve

0.433s ERROR Loading crate
0.433s ERROR Found package NodeIndex(0)
0.433s ERROR err=Other(Failed to find target my-lib.
It looks like you are trying to build dioxus in a library crate. You either need to run dx from inside a binary crate or build a specific example with the `--example` flag. Available examples are:
)
```

(does not list the `frontend` package)
```
my-lib$ dx serve -p frontend

0.450s ERROR Loading crate
0.450s ERROR Could not find package frontend in the workspace. Did you forget to add it to the workspace?
0.451s ERROR Packages in the workspace:
0.451s ERROR my-lib
0.451s ERROR err=Other(Failed to find package frontend)
```

**Environment:**

- Dioxus version: `v0.6.3`
- Rust version:
```
rustc 1.86.0-nightly (124cc9219 2025-02-09)
binary: rustc
commit-hash: 124cc92199ffa924f6b4c7cc819a85b65e0c3984
commit-date: 2025-02-09
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
```
- `.cargo/config.toml`
```
[build]
target-dir = "/home/dzenan/.cargo/target/global/"

[net]
git-fetch-with-cli = true

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]
```
- OS info: `Linux 6.11.0-21-generic #21-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 19 16:50:40 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux`
- App platform: web

**Questionnaire**

I'm interested in fixing this myself but don't know where to start.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.