# Cannot build guix package with cargo build system where the cargo package to be built has a git dependency

**URL:** <https://forum.systemcrafters.net/t/cannot-build-guix-package-with-cargo-build-system-where-the-cargo-package-to-be-built-has-a-git-dependency/2121>\
**Category:** Guix\
**Created:** [September 28, 2026, 10:44am UTC](https://forum.systemcrafters.net/t/cannot-build-guix-package-with-cargo-build-system-where-the-cargo-package-to-be-built-has-a-git-dependency/2121 "2026-09-28T10:44:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Folaht](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/folaht/32/1145_2.png) [@Folaht](https://forum.systemcrafters.net/u/Folaht)\
**Post date:** [September 28, 2026, 10:44am UTC](https://forum.systemcrafters.net/t/cannot-build-guix-package-with-cargo-build-system-where-the-cargo-package-to-be-built-has-a-git-dependency/2121/1 "2026-09-28T10:44:47Z")

</div>

I’m trying to build fetchit so I can put it on my guix channel.

However, I get the following error:

```shell
$ guix build -L ~/Nwaȥ/Êsaj/Giks/yrop/ fetchit
...
starting phase `build'
error: failed to get `ant-core` as a dependency of package `fetchit-net v0.2.0 (/tmp/guix-build-fetchit-0.2.8.drv-0/source/crates/fetchit-net)`

Caused by:
  failed to load source for dependency `ant-core`

Caused by:
  Unable to update https://github.com/WithAutonomi/ant-client?rev=3df6764

Caused by:
  can't checkout from 'https://github.com/WithAutonomi/ant-client': you are in the offline mode (--offline)
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "cargo" arguments: ("build" "--offline" "-j" "4" "--release") exit-status: 101 term-signal: #f stop-signal: #f> 
phase `build' failed after 0.4 seconds
command "cargo" "build" "--offline" "-j" "4" "--release" failed with status 101
build process 6 exited with status 256
builder for `/gnu/store/n6ljiwd9fa3xngpckn5pmq0640w4908h-fetchit-0.2.8.drv' failed with exit code 1

```

fetchit.scm

```auto
...
  #:use-module (yrop packages ant core))

(define %fetchit-cargo-lock
  (or (search-path %load-path "yrop/files/fetchit-Cargo.lock")
      (error "could not find fetchit-Cargo.lock in load path")))

(define %cargo-inputs
  (cargo-inputs-from-lockfile %fetchit-cargo-lock))

...
(define-public fetchit
  (package
   ...
   (build-system cargo-build-system)
   ...
        (inputs (cons* (ant-core %cargo-inputs))
   ...))
...

```

core.scm

```auto
...
  #:export (ant-core))

(define %ant-client-cargo-lock
  (or (search-path %load-path "yrop/files/ant-client-3df6764-Cargo.lock")
      (error "could not find ant-client-3df6764-Cargo.lock in load path")))

(define %cargo-inputs
  (cargo-inputs-from-lockfile %ant-client-cargo-lock))

...
(define-public ant-core
  (package
   ...
   (build-system cargo-build-system)
   ...
         (inputs (cons* mimalloc
                   `(,zstd "lib") %cargo-inputs))
   ...))
...

```

---

<div class="post-metadata">

**Author:** ![Folaht](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/folaht/32/1145_2.png) [@Folaht](https://forum.systemcrafters.net/u/Folaht)\
**Post date:** [October 22, 2026, 11:02am UTC](https://forum.systemcrafters.net/t/cannot-build-guix-package-with-cargo-build-system-where-the-cargo-package-to-be-built-has-a-git-dependency/2121/2 "2026-10-22T11:02:33Z")

</div>

[edit]  
This is not working yet..  
[/edit]

“Solved” by creating a guix package for the git dependency and editing the lock file to point to that package instead in the unpack phase.

_fetchit-cli.scm (previously fetchit.scm)_

```auto
...
#:use-module (yrop packages ant core))

(define %fetchit-cli-cargo-lock
  (in-vicinity (current-source-directory)
               "../../files/cargo/fetchit-cli-Cargo.lock"))

(define %fetchit-cli-cargo-inputs
  (cargo-inputs-from-lockfile %fetchit-cli-cargo-lock))

(define %ant-core-cargo-lock
  (in-vicinity (current-source-directory)
               "../../files/cargo/ant-client-3df6764-Cargo.lock"))

(define %ant-core-cargo-inputs
  (cargo-inputs-from-lockfile %ant-core-cargo-lock))

(define %ant-core-crate
  (file-append rust-ant-core "/share/cargo/registry/ant-core-0.2.4.crate"))
...

(define-public fetchit
  (package
   ...
   (build-system cargo-build-system)
   ...
(add-after 'unpack 'use-local-ant-core
          (lambda _
            ;; A. unpack local crate 
            (mkdir "guix-ant-core")
            (invoke "tar" "xf" #$%ant-core-crate "-C" "guix-ant-core" "--strip-components=1")
            
            ;; B. substitute git source with local package
            (substitute* "Cargo.toml"
              (("ant-core = \\{ git = \"https://github.com/WithAutonomi/ant-client\", rev = \"3df6764\" \\}")
               "ant-core = { version = \"0.2.4\", path = \"guix-ant-core\" }"))
            (substitute* "crates/fetchit-core/Cargo.toml"
              (("ant-core = \\{ git = \"https://github.com/WithAutonomi/ant-client\", rev = \"3df6764\" \\}")
               "ant-core = { version = \"0.2.4\", path = \"../../guix-ant-core\" }"))
            (substitute* "crates/fetchit-net/Cargo.toml"
              (("ant-core = \\{ git = \"https://github.com/WithAutonomi/ant-client\", rev = \"3df6764\" \\}")
               "ant-core = { version = \"0.2.4\", path = \"../../guix-ant-core\" }"))
            
            ;; C. neutralize git-source further
            (substitute* "Cargo.lock"
              (("source = \"git\\+https://github.com/WithAutonomi/ant-client\\?rev=3df6764#[a-f0-9]+\"")
               "source = \"registry+https://github.com/rust-lang/crates.io-index\"")) 

            #t))
   ...     
        (inputs (cons* (ant-core %cargo-inputs))
   ...))

```
