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

Issue running example code and using in project #14

Open
scizzorz opened this issue Jun 8, 2020 · 7 comments
Open

Issue running example code and using in project #14

scizzorz opened this issue Jun 8, 2020 · 7 comments

Comments

@scizzorz
Copy link

scizzorz commented Jun 8, 2020

Hello!

I was really struggling to understand the git2 callbacks for authentication and how I can make them behave the same way the standard git binary behaves out of the box, so this library seems extremely promising to me. Unfortunately, I've cloned the repo and tried to run the example, but it doesn't seem to work.

» cargo run --example clone -- --nocapture
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/examples/clone --nocapture`
Error: Error { code: -1, klass: 12, message: "unsupported URL protocol" }

Modifying the git2 dependency to not disable the default features yields a different error message:

diff --git a/Cargo.toml b/Cargo.toml
index c852..7254 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ exclude = ["/.github", ".dependabot/", "/docs/**", "/scripts", ".gitignore", "/t

 [dependencies]
 dirs = "2.0"
-git2 = { version = "^0.13", default-features = false }
+git2 = { version = "^0.13"}
 dialoguer = { version = "0.6.2", optional = true }
» cargo run --example clone -- --nocapture
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/examples/clone --nocapture`
Error: Error { code: -1, klass: 23, message: "error authenticating: no auth sock variable" }

This same error pops up when I try to use this library in the project I'd actually like to use it in, so it stretches beyond just the example not working. I see in #9 and in https://github.com/davidB/git2_credentials/blob/master/src/ssh_config.rs#L9 that SSH keys should be supported, but I don't know how to enable them.

If there's some gitconfig setting that I need to update, that might be helpful to know, but I would like to know more information about how and why git itself doesn't require that setting to work as I expect.

Thanks!

@scizzorz scizzorz changed the title Issue using Issue running example code and using in project Jun 8, 2020
@davidB
Copy link
Owner

davidB commented Jun 8, 2020

Thanks for reporting the issue.
I removed the default feature from the git2 dependencies to not force them to user, the crate doesn't need the default git2's default feature. But the support of ssh / git scheme is provided as a git2's feature.
I fixed the dependencies for examples.
You can use the published crate for your project with the git2 dependencies, just not disabled the git2 features ;-). I used this crate into an other project if you want to see an other example: https://github.com/ffizer/ffizer/blob/master/src/git.rs#L57

Sorry for the issue.

@davidB
Copy link
Owner

davidB commented Jun 8, 2020

I forgot the second part of your question: the detection of the ssh config to used doesn't cover all case. What is currently "supported/tested" ?

  • works with ssh-agent / ssh-add (It's what I used with git cli and git2_credentials)
  • store the ssh configuration into a file named $HOME/.ssh/id_rsa or $HOME/.ssh/id_ed25519 and ask passphrase (I don't use it, maybe there is a bug)
  • http authentication

I don't know about "error authenticating: no auth sock variable" but I'm interested to have a solution.

@davidB
Copy link
Owner

davidB commented Jun 8, 2020

What is the output of ?

env | grep SSH_AUTH_SOCK

does the file exist ?

@scizzorz
Copy link
Author

scizzorz commented Jun 8, 2020

I do not have $SSH_AUTH_SOCK defined in my environment. When I set it via:

eval $(ssh-agent)

and re-run my project, it appears to be stuck in an infinite loop. This may be caused by my code rather than a bug in the library, but I haven't looked into debugging it at all.

@davidB
Copy link
Owner

davidB commented Oct 6, 2020

@scizzorz did you find if the issue on this crate or on your side ?

@scizzorz
Copy link
Author

scizzorz commented Oct 6, 2020

I did not. I ended up copying and pasting code from Cargo and then modifying it to suit my project's needs. Here's my modified code: https://github.com/xtfc/mold/blob/master/src/cargo.rs

@davidB
Copy link
Owner

davidB commented Oct 6, 2020

Ok, thanks for the link

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

2 participants