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

Using cargo generate as described in the game of life example not working #52

Open
bravecorvus opened this issue May 26, 2019 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@bravecorvus
Copy link

bravecorvus commented May 26, 2019

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

  1. cargo install cargo-generate
  2. cargo generate --git https://www.github.com/rustwasm/wasm-pack-template
  3. 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.

img

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

@bravecorvus bravecorvus added the bug Something isn't working label May 26, 2019
@fitzgen
Copy link
Member

fitzgen commented Jun 3, 2019

This seems like a bug in cargo-generate. cc @ashleygwilliams

@fitzgen
Copy link
Member

fitzgen commented Jun 3, 2019

Did you have network access? Was there any other output afterwards?

@bravecorvus
Copy link
Author

I do.

I tried again right now, and i got a slightly different error

img

@bravecorvus
Copy link
Author

bravecorvus commented Jun 3, 2019

Ya think this could be related to this?

@ashleygwilliams
Copy link
Member

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!

@ashleygwilliams ashleygwilliams self-assigned this Jun 4, 2019
@bravecorvus
Copy link
Author

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.

@svenfoo
Copy link

svenfoo commented Sep 11, 2019

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 rust-lang/rust#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 branch master
The command "cargo generate --git . --name testing" exited with 0.

@Kelvinm
Copy link

Kelvinm commented Jun 15, 2020

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

@RiderSargent
Copy link

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:

Screenshot 2020-06-19 at 10 35 13

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)

@bravecorvus
Copy link
Author

@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.

@tuzz
Copy link

tuzz commented Jun 23, 2020

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:

  1. cargo-generate calls git::create which is returning an error result here

  2. git::create uses GitRemote to checkout the project here

  3. That's coming from cargo::sources. Here's the GitRemote::checkout function

  4. There's a format_error proc 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".

  1. There's a call to fetch that calls format_error with "clone" here

  2. fetch is 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

@ezpuzz
Copy link

ezpuzz commented Aug 28, 2020

I had this issue. Fixed with workarounds described here: cargo-generate/cargo-generate#168

workaround: remove url rewrites from your ~/.gitconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants