rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
54.01k stars 10.15k forks source link

The `rustlings init` command failed in the root directory but worked in the `exercises` directory. #2139

Closed Salvely closed 2 weeks ago

Salvely commented 2 weeks ago

[!NOTE]

I know where I got wrong now, I shouldn't have installed from the source code. This issue will be closed.

I am working on rustlings in the codespaces, by clikcking create a codespaces on main under the green code button in the repository. I am using the rustc 1.84.0-nightly compiler and I use the git://mirrors.ustc.edu.cn/crates.io-index mirror source as the package source.

I encountered this problem today when I am initializing rustlings. It works well when installing the rustlings using cargo. But every time I entered the rustlings init, It says that:

@Salvely ➜ /workspaces/rustlings (main) $ rustlings
Error: You are trying to run Rustlings using the old method before version 6.
The new method doesn't include cloning the Rustlings' repository.
Please follow the instructions in `README.md`:
https://github.com/rust-lang/rustlings#getting-started

I looked into the documentation, and I tried the method there. But it didn't work. Then I tried another method:

cd exercises
rustlings init

Then it successfully printed out the prompts:

@Salvely ➜ /workspaces/rustlings/exercises (main) $ rustlings init
This command will create the directory `rustlings/` as a member of this Cargo workspace.
Press ENTER to continue 

two packages named `rustlings` in this workspace:
- /workspaces/rustlings/exercises/rustlings/Cargo.toml
- /workspaces/rustlings/Cargo.toml
The directory `rustlings` has been added to `workspace.members` in the `Cargo.toml` file of this Cargo workspace.
Initialization done ✓

Run `cd rustlings` to go into the generated directory.
Then run `rustlings` to get started.

It works.

0xKurt commented 1 week ago

Thanks man!