How to build multi workspace cargo project in rust
up vote
0
down vote
favorite
I have multi-workspace Cargo project. It has two workspaces, common
and server
. common
is a lib
project and server is a bin
project.
The location of the project in Github is here.
Below is the project structure.
.
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── README.md
└── server
├── Cargo.toml
└── src
└── main.rs
4 directories, 6 files
And the file contents of ./Cargo.toml file is
[package]
name = "multi_module_cargo_project"
version = "0.1.0"
authors = ["rajkumar"]
[workspace]
members = ["common", "server"]
[dependencies]
When I run the command cargo build --all
:
error: failed to parse manifest at `/home/rajkumar/Coding/Rust/ProgrammingRust/multi_module_cargo_project/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
So I added below in Cargo.toml
but still couldn't build the project.
[[bin]]
name = "server/src/main.rs"
How can I build the project. What I'm missing?
rust rust-cargo
add a comment |
up vote
0
down vote
favorite
I have multi-workspace Cargo project. It has two workspaces, common
and server
. common
is a lib
project and server is a bin
project.
The location of the project in Github is here.
Below is the project structure.
.
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── README.md
└── server
├── Cargo.toml
└── src
└── main.rs
4 directories, 6 files
And the file contents of ./Cargo.toml file is
[package]
name = "multi_module_cargo_project"
version = "0.1.0"
authors = ["rajkumar"]
[workspace]
members = ["common", "server"]
[dependencies]
When I run the command cargo build --all
:
error: failed to parse manifest at `/home/rajkumar/Coding/Rust/ProgrammingRust/multi_module_cargo_project/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
So I added below in Cargo.toml
but still couldn't build the project.
[[bin]]
name = "server/src/main.rs"
How can I build the project. What I'm missing?
rust rust-cargo
1
I think you should only put[workspace]
inside the root manifest and so remove[package]
and[dependencies]
, put that only in the manifest insideserver
andcommon
.
– Stargateur
Nov 3 at 17:27
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have multi-workspace Cargo project. It has two workspaces, common
and server
. common
is a lib
project and server is a bin
project.
The location of the project in Github is here.
Below is the project structure.
.
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── README.md
└── server
├── Cargo.toml
└── src
└── main.rs
4 directories, 6 files
And the file contents of ./Cargo.toml file is
[package]
name = "multi_module_cargo_project"
version = "0.1.0"
authors = ["rajkumar"]
[workspace]
members = ["common", "server"]
[dependencies]
When I run the command cargo build --all
:
error: failed to parse manifest at `/home/rajkumar/Coding/Rust/ProgrammingRust/multi_module_cargo_project/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
So I added below in Cargo.toml
but still couldn't build the project.
[[bin]]
name = "server/src/main.rs"
How can I build the project. What I'm missing?
rust rust-cargo
I have multi-workspace Cargo project. It has two workspaces, common
and server
. common
is a lib
project and server is a bin
project.
The location of the project in Github is here.
Below is the project structure.
.
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── README.md
└── server
├── Cargo.toml
└── src
└── main.rs
4 directories, 6 files
And the file contents of ./Cargo.toml file is
[package]
name = "multi_module_cargo_project"
version = "0.1.0"
authors = ["rajkumar"]
[workspace]
members = ["common", "server"]
[dependencies]
When I run the command cargo build --all
:
error: failed to parse manifest at `/home/rajkumar/Coding/Rust/ProgrammingRust/multi_module_cargo_project/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
So I added below in Cargo.toml
but still couldn't build the project.
[[bin]]
name = "server/src/main.rs"
How can I build the project. What I'm missing?
rust rust-cargo
rust rust-cargo
edited Nov 3 at 18:58
Peter Hall
14.2k73778
14.2k73778
asked Nov 3 at 17:11
Rajkumar Natarajan
9041032
9041032
1
I think you should only put[workspace]
inside the root manifest and so remove[package]
and[dependencies]
, put that only in the manifest insideserver
andcommon
.
– Stargateur
Nov 3 at 17:27
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35
add a comment |
1
I think you should only put[workspace]
inside the root manifest and so remove[package]
and[dependencies]
, put that only in the manifest insideserver
andcommon
.
– Stargateur
Nov 3 at 17:27
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35
1
1
I think you should only put
[workspace]
inside the root manifest and so remove [package]
and [dependencies]
, put that only in the manifest inside server
and common
.– Stargateur
Nov 3 at 17:27
I think you should only put
[workspace]
inside the root manifest and so remove [package]
and [dependencies]
, put that only in the manifest inside server
and common
.– Stargateur
Nov 3 at 17:27
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You included a [package]
section in your main Cargo.toml
file. This section indicates that you want to build a main package in addition to the packages in the workspace. However, you don't have any source files for the main package, so Cargo complains.
The solution is to simply omit the [package]
section, and only include [workspace]
. This configures a virtual workspace – a workspace that is only a container for member packages, but does not build a package itself.
See the main Cargo.toml
file of Rocket for a real-world example of a virtual workspace, and Tokio for a real-world example of a workspace with a main package.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You included a [package]
section in your main Cargo.toml
file. This section indicates that you want to build a main package in addition to the packages in the workspace. However, you don't have any source files for the main package, so Cargo complains.
The solution is to simply omit the [package]
section, and only include [workspace]
. This configures a virtual workspace – a workspace that is only a container for member packages, but does not build a package itself.
See the main Cargo.toml
file of Rocket for a real-world example of a virtual workspace, and Tokio for a real-world example of a workspace with a main package.
add a comment |
up vote
1
down vote
accepted
You included a [package]
section in your main Cargo.toml
file. This section indicates that you want to build a main package in addition to the packages in the workspace. However, you don't have any source files for the main package, so Cargo complains.
The solution is to simply omit the [package]
section, and only include [workspace]
. This configures a virtual workspace – a workspace that is only a container for member packages, but does not build a package itself.
See the main Cargo.toml
file of Rocket for a real-world example of a virtual workspace, and Tokio for a real-world example of a workspace with a main package.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You included a [package]
section in your main Cargo.toml
file. This section indicates that you want to build a main package in addition to the packages in the workspace. However, you don't have any source files for the main package, so Cargo complains.
The solution is to simply omit the [package]
section, and only include [workspace]
. This configures a virtual workspace – a workspace that is only a container for member packages, but does not build a package itself.
See the main Cargo.toml
file of Rocket for a real-world example of a virtual workspace, and Tokio for a real-world example of a workspace with a main package.
You included a [package]
section in your main Cargo.toml
file. This section indicates that you want to build a main package in addition to the packages in the workspace. However, you don't have any source files for the main package, so Cargo complains.
The solution is to simply omit the [package]
section, and only include [workspace]
. This configures a virtual workspace – a workspace that is only a container for member packages, but does not build a package itself.
See the main Cargo.toml
file of Rocket for a real-world example of a virtual workspace, and Tokio for a real-world example of a workspace with a main package.
answered Nov 4 at 10:04
Sven Marnach
335k75737685
335k75737685
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53133637%2fhow-to-build-multi-workspace-cargo-project-in-rust%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
I think you should only put
[workspace]
inside the root manifest and so remove[package]
and[dependencies]
, put that only in the manifest insideserver
andcommon
.– Stargateur
Nov 3 at 17:27
@Stargateur - You are right. That works. I would've accepted your answer if you answered the question.
– Rajkumar Natarajan
Nov 3 at 18:35