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

cargo: error on building fresh project #22822

Closed
alexreg opened this issue Feb 26, 2015 · 5 comments
Closed

cargo: error on building fresh project #22822

alexreg opened this issue Feb 26, 2015 · 5 comments

Comments

@alexreg
Copy link
Contributor

alexreg commented Feb 26, 2015

I create a new project using cargo new hello_world --bin, and then run cargo build -v, but get the following error.

Process didn't exit successfully: `rustc - --crate-name - --crate-type dylib --crate-type bin --print=file-names` (status=101)
--- stderr
error: crate name cannot start with a hyphen: -
error: aborting due to previous error

This error just started appearing since I updated to the latest nightly.

Incidentally, there seems to be no different to the Cargo.toml file or directory structure or indeed main.rs file, regardless of whether I specify the --bin option or not to cargo new. Is this right?

@dguo
Copy link

dguo commented Feb 26, 2015

See rust-lang/cargo#1342

@alexreg
Copy link
Contributor Author

alexreg commented Feb 26, 2015

Ah okay, so it should be fixed in the next nightly?

Any idea about the second issue (re —bin), incidentally?

On 26 Feb 2015, at 01:58, Danny Guo notifications@github.com wrote:

See rust-lang/cargo#1342 rust-lang/cargo#1342

Reply to this email directly or view it on GitHub #22822 (comment).

@dguo
Copy link

dguo commented Feb 26, 2015

Yes, I assume the fix will be in the next nightly.

There should be a difference. Specifically, leaving off --bin should give you a .gitignore with Cargo.lock in it. See rust-lang/cargo#315

In src, you should also have a lib.rs file with a test function instead of main.rs with main.

Maybe double check to make sure you aren't specifying --bin? I just tried again, and it works fine for me. I am also on the latest nightly.

@alexreg
Copy link
Contributor Author

alexreg commented Feb 26, 2015

Thanks for confirming.

And yes, my bad; I must have been too hasty in checking the src/ dirs here.

On 26 Feb 2015, at 02:18, Danny Guo notifications@github.com wrote:

Yes, I assume the fix will be in the next nightly.

There should be a difference. Specifically, leaving off --bin should give you a .gitignore with Cargo.lock in it. See rust-lang/cargo#315 rust-lang/cargo#315
In src, you should also have a lib.rs file with a test function instead of main.rs with main.

Maybe double check to make sure you aren't specifying --bin? I just tried again, and it works fine for me. I am also on the latest nightly.


Reply to this email directly or view it on GitHub #22822 (comment).

@alexcrichton
Copy link
Member

Closing as a duplicate of rust-lang/cargo#1342 (this should be fixed in the next nightly)

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

3 participants