Skip to content

fetchFromGitHub with fetchSubmodules have issues with HTTPS when using an alternate nix store #345226

Open

Description

@dustyhorizon

Describe the bug

I am using fetchFromGitHub with fetchSubmodules within a buildDunePackage call to pull all git modules for a build and was working well previously.

However, after updating my nixpkgs unstable channel from ad416d066ca1222956472ab7d0555a6946746a80 to 1925c603f17fc89f4c8f6bf6f631a802ad85d784, I have been running into an error relating to missing CA certificates when rebuilding the derivation after configuring an alternate nix store (store = xxx in ~/.config/nix/nix.conf) due to how caching works within my CI environment.

+nix-store-export-outpath-oidc-s3 *failed* |   /nix/store/qng2izmydb5x2rf7as8cwlx442ax5fyd-ocaml5.2.0-semgrep-core-1.89.0.drv
+nix-store-export-outpath-oidc-s3 *failed* | building '/nix/store/mk81q6nzyzjhf7v9pvm2zcrx4q6wa73z-source.drv'...
+nix-store-export-outpath-oidc-s3 *failed* | error: builder for '/nix/store/mk81q6nzyzjhf7v9pvm2zcrx4q6wa73z-source.drv' failed with exit code 1;
+nix-store-export-outpath-oidc-s3 *failed* |        last 7 log lines:
+nix-store-export-outpath-oidc-s3 *failed* |        > exporting https://github.com/semgrep/semgrep.git (rev v1.89.0) into /nix/store/ibn8xawg0yjc8c49zg2xyf4630klgrv4-source
+nix-store-export-outpath-oidc-s3 *failed* |        > Initialized empty Git repository in /nix/store/ibn8xawg0yjc8c49zg2xyf4630klgrv4-source/.git/
+nix-store-export-outpath-oidc-s3 *failed* |        > fatal: unable to access 'https://github.com/semgrep/semgrep.git/': OpenSSL/3.0.14: error:16000069:STORE routines::unregistered scheme
+nix-store-export-outpath-oidc-s3 *failed* |        > fatal: unable to access 'https://github.com/semgrep/semgrep.git/': OpenSSL/3.0.14: error:16000069:STORE routines::unregistered scheme
+nix-store-export-outpath-oidc-s3 *failed* |        > fatal: unable to access 'https://github.com/semgrep/semgrep.git/': OpenSSL/3.0.14: error:16000069:STORE routines::unregistered scheme
+nix-store-export-outpath-oidc-s3 *failed* |        > fatal: unable to access 'https://github.com/semgrep/semgrep.git/': OpenSSL/3.0.14: error:16000069:STORE routines::unregistered scheme
+nix-store-export-outpath-oidc-s3 *failed* |        > Unable to checkout refs/tags/v1.89.0 from https://github.com/semgrep/semgrep.git.
+nix-store-export-outpath-oidc-s3 *failed* |        For full logs, run 'nix log /nix/store/mk81q6nzyzjhf7v9pvm2zcrx4q6wa73z-source.drv'.
+nix-store-export-outpath-oidc-s3 *failed* | error: 1 dependencies of derivation '/nix/store/qng2izmydb5x2rf7as8cwlx442ax5fyd-ocaml5.2.0-semgrep-core-1.89.0.drv' failed to build

Steps To Reproduce

Steps to reproduce the behavior:

  1. docker run -it --rm nixos/nix:2.23.3
  2. nix-env -iA nixpkgs.cacerts ...
  3. Configure store = /tmp/store in ~/.config/nix/nix.conf
  4. Build derivation that uses fetchFromGitHub with fetchSubmodules = true
  5. Error

Expected behavior

Source should be fetchFromGitHub-ed without errors.

Additional context

I believe this bug was due to a change to fetchGit as part of #303307

Notify maintainers

@lukegb - not sure who to ping but you since you were the approver

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.0-linuxkit`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.23.3`
 - channels(root): `"nixpkgs, nixpkgs_24_05-24.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Sep 29, 2024
  2. dustyhorizon commented on Sep 29, 2024

    @dustyhorizon
    ContributorAuthor

    911aa1440f40405f13f9252e2eb8ffc12f269090 is definitely the cause, pinning to the parent commit c455cc3170d68f05b4614c41883a7d417d1c16e0 has no issues when building the derivation.

    Nevermind, seems like 911aa1440f40405f13f9252e2eb8ffc12f269090 is fine too, seems like I am grasping at straws right now.

    Retested with a clean cache again, and that seems to point that 911aa1440f40405f13f9252e2eb8ffc12f269090 is the cause per the initial comment. I thought it was not working but turns out it was reusing the cached source left from a previous run.

  3. lukegb commented on Sep 29, 2024

    @lukegb
    Contributor

    @timbertson I think we need to make the change suggested in #303307 (comment) to check whether the file actually exists and is readable before using it.

  4. dustyhorizon commented on Sep 29, 2024

    @dustyhorizon
    ContributorAuthor

    After hours of attempting to override fetchgit and several amateur hour moments, I can confirm that NIX_SSL_CERT_FILE set within nixos/nix:2.23.3 is the culprit.

    Specifically, NIX_SSL_CERT_FILE gets inherited by nix build ... and because it still points to the original nix store within my chroot-ed store build, the file essentially does not exists (broken symlink) and the config gets propagated towards the various fetchers which breaks fetchgit in my case.

    A file existence check (in both symlinks and non symlinks conditions) should work but not too sure where is appropriate for this check.

    EDIT: Just saw @lukegb 's proposed fix, really appreciate it!

  5. timbertson commented on Sep 30, 2024

    @timbertson
    Contributor

    Thanks for the detailed report, I'll make a PR soon 👍

    Edit Just saw yours @lukegb , thanks!

  6. PedroHLC commented on Nov 3, 2024

    @PedroHLC
    Member

    Getting the same result with nixpkgs/cachix-flakes:latest, started around the time of this issue, and still affects it.

  7. self-assigned this
    on Nov 3, 2024
  8. added
    2.status: stale
    on Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

0.kind: bug2.status: stale

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions