What cargo config? I see no cargo config

I installed Rust following the instructions in the Rust Book. Everything seems to be working except that Cargo creates no git repository without me explicitly telling it to do so on the command line. The book indicates that the creation of the git repo should be the default. When I went looking for how to force the issue, all roads pointed to ~/.cargo/config. I see no such beastie anywhere on my system

$ sudo find / -name "*config*" | grep cargo
[sudo] password for ...: 
find: ‘/run/user/1001/gvfs’: Permission denied
$

I have:

$ ls -R ~/.cargo/
/home/.../.cargo/:
bin  env  registry

/home/.../.cargo/bin:
cargo  rls  rustc  rustdoc  rust-gdb  rust-lldb  rustup

/home/.../.cargo/registry:
index

/home/.../.cargo/registry/index:
github.com-1ecc6299db9ec823

/home/.../.cargo/registry/index/github.com-1ecc6299db9ec823:
$

(Adding a -A revealed there's a git repo in the ~/.cargo/registry/index/github.com-1ecc6299db9ec823/ directory.)

Just to be clear, you're talking about this procedure, right?

And if so, the following:

cargo new hello_world --bin

ls -la hello_world

-rw-rw-r--  1 adrian adrian 122 Oct 14 13:52 Cargo.toml
drwxrwxr-x  6 adrian adrian 180 Oct 14 13:52 .git
-rw-rw-r--  1 adrian adrian  20 Oct 14 13:52 .gitignore
drwxrwxr-x  2 adrian adrian  60 Oct 14 13:52 src

…doesn't work?

Cargo does not create this file for you; if you want something in it, you have to make it.

That said, I'm not sure why Cargo isn't creating a repo for you....

I think it ought to create an empty stub for ~/.cargo/config, just to communicate to users that they've found the right path.

I mean, yeah, it's common for things like ~/.Xmodmap and ~/.pylintrc to not exist by default because they directly pollute your home directory; but ~/.cargo already exists for other reasons.

RE: Git repos, the only thing that comes to mind is that, if you're technically inside a repo (e.g. one of the parent directories is a repo), then it won't make one.

Well. That was terribly embarrassing. Months ago, I set up a folder for learning Rust, and had set it aside. Now that I'm finding time to get back to it, I went to that directory to continue with the book. What I did not remember, is that at the very top level of my ~/Learn/rust/ tree is that I had initialized a git repo. So, from within ~/Learn/rust, when I used cargo, I was indeed creating a cargo project within an existing Git repo.

My apologies, all.

1 Like

I like having a git indicator in my terminal prompt, so that I'm never lost :wink:

git-prompt

4 Likes