Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error in finding root toml file. #2

Open
nathankg opened this issue Aug 16, 2023 · 0 comments
Open

build error in finding root toml file. #2

nathankg opened this issue Aug 16, 2023 · 0 comments

Comments

@nathankg
Copy link

nathankg commented Aug 16, 2023

Hi! when trying to build a docker image, I'm running into this issue where when I run cargo cog build, the path to my root package is resolving incorrectly.

I have the following file structure:

matchmaker/ (workspace root)
  ├── Cargo.toml (root package)
  ├── src/ (root package source code)
  ├── matchmaker-js/ (child package)
  │     ├── Cargo.toml (child package's Cargo configuration)
  │     └── src/ (child package source code)
  └── test_utils/ (child package)
        ├── Cargo.toml (child package's Cargo configuration)
        └── src/ (child package source code)

And then I'm running the build command (RUST_BACKTRACE=1 cargo cog build -t matchmaker-service-image) in the matchmaker (root) directory.

My root toml file looks like below:

# matchmaker/Cargo.toml
[package]
edition = "2021"
name = "matchmaker"
version = "0.0.11"
authors = ["<...>"]

[package.metadata.cog]
image = "matchmaker-service-image" # optional, defaults to `cog-[package.name]`

[workspace]
members = [".", "server", "matchmaker-js", "test_utils"]
default-members = ["."]

[dependencies]
bytemuck = { version = "1.13.1", features = ["derive"] }
chef = "0.1.0"
cog-rust = "1.0.14"
env_logger = "0.10.0"
futures = "0.3.28"
futures-intrusive = "0.5.0"
handlebars = "4.3.7"
lazy_static = "1.4.0"
log = "0.4.19"
rayon = "1.7.0"
regex = "1.9.1"
serde_json = "1.0.103"
tokio = { version = "1.29.1", features = ["rt", "rt-multi-thread", "macros"] }
wgpu = "0.17.0"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["async_tokio", "html_reports"] }
test_utils = { path = "./test_utils" }

[profile.release]
lto = true

[[bench]]
name="compatibility"
harness=false

[[bench]]
name="matching"
harness=false

Based on the error output, it seems like the matchmaker package is resolving to src/matchmaker/Cargo.toml instead of the intended src/Cargo.toml.

...
 => ERROR [builder 5/7] RUN cargo chef cook --release --bin matchmaker                                                                         0.7s
------
 > [builder 5/7] RUN cargo chef cook --release --bin matchmaker:
0.637 error: failed to load manifest for workspace member `/src/matchmaker`
0.637
0.637 Caused by:
0.637   failed to read `/src/matchmaker/Cargo.toml`
0.637
0.637 Caused by:
0.637   No such file or directory (os error 2)
0.639 thread 'main' panicked at 'Exited with status code: 101', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.62/src/recipe.rs:204:27
0.639 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------
Dockerfile:12
--------------------
  10 |     RUN curl -L --proto '=https' --tlsv1.2 -sSf "https://github.com/cargo-bins/cargo-quickinstall/releases/download/cargo-deb-1.44.0/cargo-deb-1.44.0-x86_64-unknown-linux-gnu.tar.gz" | tar -xzvvf - -C /usr/local/cargo/bin
  11 |     COPY --from=planner /src/recipe.json recipe.json
  12 | >>> RUN cargo chef cook --release --bin matchmaker
  13 |     COPY . .
  14 |     RUN cargo deb --output /src/target/matchmaker.deb
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo chef cook --release --bin matchmaker" did not complete successfully: exit code: 101
thread 'main' panicked at 'Failed to build docker image.', /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-cog-1.0.9/src/docker/builder.rs:239:9
...

I began to wonder if I'm referencing the root package wrong as a dependency, but even in my child packages, I refer to the matchmaker package as a dependency using the relative path: ".."

e.g.

# matchmaker/server/Cargo.toml
[package]
edition = "2021"
name = "matchmaker-server"
version = "0.0.1"
workspace = ".."

[dependencies]
matchmaker = { path = ".." }
tonic = "0.9.2"
prost = "0.11.9"
tokio = "1.29.1"

[build-dependencies]
tonic-build = "0.9.2"

New to rust and even newer to cog-rust, so very possible I missed specifying the appropriate key or field in the manifest. Any thoughts or help would be super appreciated :)

@nathankg nathankg changed the title cargo cog build error finding root toml file. build error in finding root toml file. Aug 16, 2023
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

No branches or pull requests

1 participant