Using `cargo generate` as described in the game of life example not working
Describe the Bug
I was following the example code at https://rustwasm.github.io/docs/book/game-of-life/setup.html.
I was able to install cargo install cargo-generate without a problem, and also have the latest LTS version of NPM. (Also, did a rustup update this morning to update my stable installation of rustc and cargo.)
However, when I run cargo generate --git https://www.github.com/rustwasm/wasm-pack-template and name my project wasm-game-of-life, it fails to clone with the error â›” Git Error: failed to clone into: /Users/andrewlee/Documents/Projects/Personal/Rust/wasm-game-of-life4g21l6
Steps to Reproduce
-
cargo install cargo-generate -
cargo generate --git https://www.github.com/rustwasm/wasm-pack-template - Name project
If applicable, add a link to a test case (as a zip file or link to a repository we can clone).
Expected Behavior
Not sure but I assume it should have set up a nice webasm project for me.
Actual Behavior
â›” Git Error: failed to clone into: /Users/andrewlee/Documents/Projects/Personal/Rust/wasm-game-of-life4g21l6
If applicable, add screenshots to help explain your problem.

Additional Context
OS: macOS 10.14.5 cargo version: cargo 1.35.0 (6f3e9c367 2019-04-04) rustc version: rustc 1.35.0 (3c235d560 2019-05-20) npm version: 6.4.1 node version: v10.15.3 git version: git version 2.21.0
This seems like a bug in cargo-generate. cc @ashleygwilliams
Did you have network access? Was there any other output afterwards?
I do.
I tried again right now, and i got a slightly different error

Ya think this could be related to this?
hrm. will have to investigate- having just released another CLI tool that leverages this under the hood and having tested it extensively on multiple platforms with a gallery of templates- i'm not entirely sure what could cause this bug! my expectation is that it is likely associated with our use of libgit2...but i'll have to look into it. thank you so much for filing and sorry you are running into this!
Thanks @ashleygwilliams . I really enjoyed watching the talk you did in Kyiv, Ukraine in April of 2017. And thanks @fitzgen for the initial response. Yall keep up the good work.
I am seeing the same problem, or is it a different one?
The Travis CI rules installed with the game of life tutorial template tell it to use cargo-generate version 0.2. However that version can not be used any longer as liquid v0.15.0 doesn't compile due to an accepted regression in Rust, see https://github.com/rust-lang/rust/issues/60958
I tried to change the rules to use cargo-generate version 0.4, but that leads to a failure later when cargo-generate is actually being run:
$ cargo generate --git . --name testing Creating project called
testing... Git Error: failed to find branchmasterThe command "cargo generate --git . --name testing" exited with 0.
Hi, is this still being looked into?
@ashleygwilliams ,
Sorry, just wanted to bring this to your attention.
@RiderSargent,
I've found someone who created a docker image with the environment set up. I struggled to try to build it myself out of masochism, but his seems to be relatively stable as a workaround (hopefully temporarily)
https://users.rust-lang.org/t/tutorial-conways-game-of-life-in-rust-and-webassembly/16823
I'm also still getting this error (@gilgameshskytrooper's original issue).
Are there any workarounds? Perhaps regarding absolute/relative paths or something?
Did you ever get this working @gilgameshskytrooper?
It looks like it is tagging six alphanumeric chars onto the end of the path it's trying to clone into, but they seem to be new random chars every time:
Please let me know if there's any further info that could help.
Thanks!
My setup: OS: macOS 10.15.5 Cargo version: cargo 1.44.0 (05d080faa 2020-05-06) rustc version: rustc 1.44.0 (49cae5576 2020-06-01) npm version: 6.14.4 node version: v12.18.0 git version: git version 2.24.3 (Apple Git-128) (hub version 2.14.2)
@RiderSargent I have not. Sorry. But I haven't tried for quite some time so I'm not sure if this is still an issue.
Hello, for context, it's working for me for the non-www URL. My setup:
- macOS 10.14.6
- cargo 1.46.0-nightly (089cbb80b 2020-06-15)
- rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)
- npm version 6.11.3
- node version 12.4.0
- git version 2.23.0
I did a bit of digging:
-
cargo-generate calls
git::createwhich is returning an error result here -
git::createusesGitRemotetocheckoutthe project here -
That's coming from
cargo::sources. Here's theGitRemote::checkoutfunction -
There's a
format_errorproc that's building the error message here
The console output from @RiderSargent's screenshot shows "failed to clone", so we know the operation argument is "clone".
-
There's a call to
fetchthat callsformat_errorwith "clone" here -
fetchis defined in the same file here
That's as far as I got. It looks like something is failing in that fetch function, but I don't know what. There are references to git2 and the "command-line" git in the function so maybe check if upgrading libgit helps.
Perhaps it would be possible to create a minimal example that calls that function directly - or to checkout the cargo project and point cargo-generate to it in Cargo.toml and trace it through with some println! statements.
As a workaround in the short-term, perhaps you can avoid cargo-generate for now and clone the repository manually. You'd have to replace the interpolations manually (e.g. {{author}}). I don't know how difficult that would be. Alternatively, if you just want a barebones wasm project, I have an example project here: https://github.com/tuzz/minimal-rust-wasm
I had this issue. Fixed with workarounds described here: https://github.com/ashleygwilliams/cargo-generate/issues/168
workaround: remove url rewrites from your ~/.gitconfig