siemens / kas

Setup tool for bitbake based projects
MIT License
363 stars 147 forks source link

Issues with fetching via git (GIT_CREDENTIAL_HELPER ?) #127

Open redeexpressos opened 1 month ago

redeexpressos commented 1 month ago

Hi. Im trying to build a recipe that will need git cli access (https://github.com/rust-embedded/meta-rust-bin/issues/185) I've looked at docs and found GIT_CREDENTIAL_HELPER, but not sure how to use it. Can I get some guidance? Im not sure if the issue is related to meta-rust-bin, or the way I'm using kas.

fmoessbauer commented 1 month ago

Hi, does the fetch work if running it without kas? Before using the credential helper, did you try the following:

Further, please also check if git rewrites (insteadof) are needed. In case you run in a CI (like GitHub actions), you probably can use webfactory/ssh-agent. This is detected by kas and the environment is prepared accordingly.

I would also recommend to have a look at the Credential Handling part of our docs.

redeexpressos commented 1 month ago

Im not sure if I can fetch Rust crates via ssh, since they are based on http. On my "local setup", when I build the software, the program usually asks for git "username" and "password". I suppose this is failing because kas cant provide these fields automatically

fmoessbauer commented 1 month ago

Im not sure if I can fetch Rust crates via ssh, since they are based on http

This definitely works, but you need to setup the insteadof rules. Example: git config url."ssh://git@github.com".insteadOf "https://github.com" (or vice versa). Please also see https://kas.readthedocs.io/en/latest/userguide/credentials.html#git-configuration

the program usually asks for git "username" and "password".

You can add these to a .netrc file and set NETRC_FILE=<path/to/.netrc>.

There are various options. Once you find a working combination, please also let us know, so we can add this example to the documentation.

redeexpressos commented 1 month ago

Ok. After putting the ssh... insteadOF https ... Im having a different error now, related to known hosts:

| Caused by:
|   error: unknown SSH host key
|   The SSH host key for `abc.def.com` is not known and cannot be validated.

Im using SSH_AUTH_SOCK='true'. Am I missing something?

Looks like I am misuing ssh_auth_sock, but can't see any examples on this without running manually ssh-agent and passing the agent...

redeexpressos commented 1 month ago

Ive tried the NETRC method.

machine https://abc.def.com
login my.name
password yes

but looks like its attempting login per repository instead :|

redeexpressos commented 1 month ago

Weird, looks like this is more an issue for Cargo and meta-rust-bin than here. After passing the NETRC file, I can git clone stuff from abc.def, but my recipe fails. Ran out of ideas.