{"action":"closed","issue":{"url":"https://api.github.com/repos/alexcrichton/git2-rs/issues/329","repository_url":"https://api.github.com/repos/alexcrichton/git2-rs","labels_url":"https://api.github.com/repos/alexcrichton/git2-rs/issues/329/labels{/name}","comments_url":"https://api.github.com/repos/alexcrichton/git2-rs/issues/329/comments","events_url":"https://api.github.com/repos/alexcrichton/git2-rs/issues/329/events","html_url":"https://github.com/alexcrichton/git2-rs/issues/329","id":339256415,"node_id":"MDU6SXNzdWUzMzkyNTY0MTU=","number":329,"title":"authentication required but no callback set","user":{"login":"promethe42","id":998703,"node_id":"MDQ6VXNlcjk5ODcwMw==","avatar_url":"https://avatars1.githubusercontent.com/u/998703?v=4","gravatar_id":"","url":"https://api.github.com/users/promethe42","html_url":"https://github.com/promethe42","followers_url":"https://api.github.com/users/promethe42/followers","following_url":"https://api.github.com/users/promethe42/following{/other_user}","gists_url":"https://api.github.com/users/promethe42/gists{/gist_id}","starred_url":"https://api.github.com/users/promethe42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/promethe42/subscriptions","organizations_url":"https://api.github.com/users/promethe42/orgs","repos_url":"https://api.github.com/users/promethe42/repos","events_url":"https://api.github.com/users/promethe42/events{/privacy}","received_events_url":"https://api.github.com/users/promethe42/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-08T20:46:55Z","updated_at":"2018-07-08T21:20:25Z","closed_at":"2018-07-08T21:20:25Z","author_association":"NONE","body":"I'm using an env var to get the path to the SSH private key.\r\nThis key is a passphrase-less GitLab deploy key. That key works great when I use it with a classic `git clone`.\r\n\r\nBut it doesn't work with `RepoBuilder::clone()`.\r\n\r\n## Expected result\r\n\r\nRepository is cloned.\r\n\r\n## Actual result\r\n\r\nThe following error:\r\n\r\n```\r\nauthentication required but no callback set; class=Ssh (23)\r\n```\r\n\r\n## How to reproduce\r\n\r\n```rust\r\npub fn git_credentials_callback(\r\n    _user: &str,\r\n    _user_from_url: Option<&str>,\r\n    _cred: git2::CredentialType,\r\n) -> Result<git2::Cred, git2::Error> {\r\n    match env::var(\"GPM_SSH_KEY\") {\r\n        Ok(k) => {\r\n            debug!(\"authenticate with private key located in {}\", k);\r\n            \r\n            git2::Cred::ssh_key(\"git\", None, std::path::Path::new(&k), None)\r\n        },\r\n        _ => Err(git2::Error::from_str(\"unable to get private key from GPM_SSH_KEY\")),\r\n    }\r\n}\r\n\r\nfn get_or_init_repo(cache : &std::path::Path, remote : &String) -> Result<git2::Repository, git2::Error> {\r\n    let data_url = match Url::parse(remote) {\r\n        Ok(data_url) => data_url,\r\n        Err(e) => panic!(\"failed to parse url: {}\", e),\r\n    };\r\n    let path = cache.deref().join(data_url.host_str().unwrap()).join(&data_url.path()[1..]);\r\n\r\n    if path.exists() {\r\n        debug!(\"use existing repository already in cache {}\", path.to_str().unwrap());\r\n        return git2::Repository::open(path);\r\n    }\r\n\r\n    let mut callbacks = git2::RemoteCallbacks::new();\r\n    callbacks.credentials(git_credentials_callback);\r\n\r\n    let mut opts = git2::FetchOptions::new();\r\n    opts.remote_callbacks(callbacks);\r\n    opts.download_tags(git2::AutotagOption::All);\r\n\r\n    let mut builder = git2::build::RepoBuilder::new();\r\n    builder.fetch_options(opts);\r\n    builder.branch(\"master\");\r\n\r\n    debug!(\"start cloning repository {} in {}\", remote, path.to_str().unwrap());\r\n    \r\n    match builder.clone(remote, &path) {\r\n        Ok(r) => {\r\n            debug!(\"repository cloned\");\r\n\r\n            Ok(r)\r\n        },\r\n        Err(e) => Err(e)\r\n    }\r\n}\r\n```\r\n\r\n"}}
{"actor":{"display_login":"promethe42"}}