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

Private crates are not supported even with net.git-fetch-with-cli = true #185

Open
redeexpressos opened this issue Jul 24, 2024 · 4 comments

Comments

@redeexpressos
Copy link

redeexpressos commented Jul 24, 2024

.cargo/config.toml:

[net]
git-fetch-with-cli = true

However, when compiling with bitbake, it cannot find the private crates.

| Caused by:
|   failed to load source for dependency `rust-protobufs`
| 
| Caused by:
|   Unable to update https://abc.com/git/rust-protobufs.git?branch=main#a27c537d
| 
| Caused by:
|   failed to clone into: /home/ubuntu/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/program/1.0+gitAUTOINC+6a7aae1cbf-r0/cargo_home/git/db/rust-protobufs-de8201c5bac7b8be
| 
| Caused by:
|   failed to authenticate when downloading repository
| 
|   * attempted to find username/password via git's `credential.helper` support, but failed
| 
|   if the git CLI succeeds then `net.git-fetch-with-cli` may help here
|   https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
| 
| Caused by:
|   failed to acquire username/password from local configuration
| WARNING: exit code 101 from a shell command.

What is the workaround for this?

@redeexpressos
Copy link
Author

Maybe related to #168

@redeexpressos
Copy link
Author

redeexpressos commented Jul 25, 2024

Also, I can login via .netrc inside my bitbake shell, and I can git clone private stuff. But looks like Cargo handles them in a weird way, so my recipe is unable to build because the software has a Cargo.toml that fetches private repositories.
Running out of ideas :(

@redeexpressos
Copy link
Author

Looks like adding netrc authentication and:

do_compile:prepend() {
    export CARGO_NET_GIT_FETCH_WITH_CLI=true
}

fixed the issue.

For some reason .cargo/config is not doing what its supposed in this bitbake shell.. I am not sure if someone can reproduce the .cargo/config part. Will wait for feedback

@jin-eld
Copy link

jin-eld commented Jan 3, 2025

The .cargo/config.toml worked for me, although later I moved to a fixup bbclass which would set the variable in do_compile:prepend as above, because that ensures builds work out of the box without additional setup.

I had another auth related issue though and it only manifested itself when we updated to Debian 10: cargo was not able to fetch anything via https, for instance, it failed fetching a public github repo:

|     Updating git repository `https://github.com/jin-eld/tls.git`
|      Running `git fetch --verbose --force --update-head-ok 'https://github.com/jin-eld/tls.git' '+refs/heads/macos-openssl:refs/remotes/origin/macos-openssl'`
| fatal: unable to access 'https://github.com/jin-eld/tls.git/': error setting certificate file: /usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/ca-certificates.crt
| error: failed to get `tokio-native-tls` as a dependency of package `client v0.1.0 (/yocto/poky-devel-build/build/work/cortexa53-crypto-poky-linux/client/git/git/lib/client)`
| 
| Caused by:
|   failed to load source for dependency `tokio-native-tls`
| 
| Caused by:
|   Unable to update https://github.com/jin-eld/tls.git?branch=macos-openssl

I was quite puzzled, especially by the /usr/local/oe-sdk-hardcoded-buildpath line and the fact, that it worked from the devshell, until I found out that GIT_SSL_CAINFO which is set by /opt/poky/5.0.5/environment-setup-x86_64-pokysdk-linux was not propagated to cargo, despite being listed in BB_ENV_PASSTHROUGH_ADDITIONS.

So my current fixup looks like this:

do_compile:prepend() {
    export CARGO_NET_GIT_FETCH_WITH_CLI=true
    export GIT_SSL_CAINFO="${GIT_SSL_CAINFO}"
}

I think it would probably make sense to add the GIT_SSL_CAINFO export to cargo_bin_do_compile() alongside the other exports, that are already there.

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