Problem
In my GitLab CI Pipeline, cargo publish fails with:
cargo publish --manifest-path share/rust/Cargo.toml --registry myregistry --no-verify --locked --allow-dirty
Updating `myregistry` index
Updating crates.io index
error: No such file or directory (os error 2)
Using CARGO_LOG=trace, I discovered that it fails while doing something git submodule related:
2026-09-09T08:22:42.003045Z 01E 0.812030412s TRACE main:exec:prepare_archive: cargo::ops::cargo_read_manifest: read_package; path=/builds/myproject/myproject/share/rust/Cargo.toml; source-id=/builds/myproject/myproject/share/rust
2026-09-09T08:22:42.006366Z 01E 0.815262897s DEBUG main:exec:prepare_archive:list_files: cargo::sources::path: list_files_gix myproject v1.1.0-git20260909082229.f9e11ae4 (/builds/myproject/myproject/share/rust)
2026-09-09T08:22:42.007405Z 01E 0.816294146s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/src/simulator.rs
2026-09-09T08:22:42.007408Z 01E 0.816315541s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/src/lib.rs
2026-09-09T08:22:42.007409Z 01E 0.816324825s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/src/sim_param.rs
2026-09-09T08:22:42.007410Z 01E 0.816333198s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/Cargo.toml
2026-09-09T08:22:42.007410Z 01E 0.816341023s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/build.rs
2026-09-09T08:22:42.032176Z 01E 0.841020226s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/.gitignore
2026-09-09T08:22:42.032181Z 01E 0.841043756s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/Cargo.lock
2026-09-09T08:22:42.032183Z 01E 0.841053781s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/examples/parameter.rs
2026-09-09T08:22:42.032184Z 01E 0.841062027s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/examples/warp.rs
2026-09-09T08:22:42.032186Z 01E 0.841071261s TRACE main:exec:prepare_archive:list_files: cargo::sources::path: found /builds/myproject/myproject/share/rust/CMakeLists.txt
2026-09-09T08:22:42.032710Z 01E 0.841616590s DEBUG main:exec:prepare_archive:check_repo_state: cargo::ops::cargo_package::vcs: found a git repo at `/builds/myproject/myproject`
2026-09-09T08:22:42.035103Z 01E 0.843990543s DEBUG main:exec:prepare_archive:check_repo_state: cargo::ops::cargo_package::vcs: found (git) Cargo.toml at `share/rust/Cargo.toml` in workdir `/builds/myproject/myproject`
2026-09-09T08:22:43.969357Z 01E 2.638926524s DEBUG cargo: exit_with_error; err=CliError { error: Some(No such file or directory (os error 2)
2026-09-09T08:22:43.969372Z 01E
2026-09-09T08:22:43.969374Z 01E Stack backtrace:
2026-09-09T08:22:43.969376Z 01E 0: <anyhow::Error as core::convert::From<gix::submodule::errors::open::Error>>::from
2026-09-09T08:22:43.969379Z 01E 1: cargo::ops::cargo_package::vcs::status_submodules
2026-09-09T08:22:43.969381Z 01E 2: cargo::ops::cargo_package::vcs::status_submodules
2026-09-09T08:22:43.969383Z 01E 3: cargo::ops::cargo_package::vcs::git
2026-09-09T08:22:43.969384Z 01E 4: cargo::ops::cargo_package::do_package
2026-09-09T08:22:43.969386Z 01E 5: cargo::ops::cargo_package::package_with_dep_graph
2026-09-09T08:22:43.969388Z 01E 6: cargo::ops::registry::publish::publish
2026-09-09T08:22:43.969390Z 01E 7: cargo::commands::publish::exec
2026-09-09T08:22:43.969391Z 01E 8: <cargo::cli::Exec>::exec
2026-09-09T08:22:43.969456Z 01E 9: cargo::main
2026-09-09T08:22:43.969458Z 01E 10: std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
2026-09-09T08:22:43.969460Z 01E 11: std::rt::lang_start::<()>::{closure#0}
2026-09-09T08:22:43.969462Z 01E 12: <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once
2026-09-09T08:22:43.969465Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/core/src/ops/function.rs:287:21
2026-09-09T08:22:43.969468Z 01E 13: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
2026-09-09T08:22:43.969470Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:576:43
2026-09-09T08:22:43.969472Z 01E 14: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe>
2026-09-09T08:22:43.969475Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:544:19
2026-09-09T08:22:43.969477Z 01E 15: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
2026-09-09T08:22:43.969480Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panic.rs:359:14
2026-09-09T08:22:43.969482Z 01E 16: std::rt::lang_start_internal::{closure#0}
2026-09-09T08:22:43.969484Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/rt.rs:175:24
2026-09-09T08:22:43.969486Z 01E 17: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize>
2026-09-09T08:22:43.969488Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:576:43
2026-09-09T08:22:43.969490Z 01E 18: std::panicking::catch_unwind::<isize, std::rt::lang_start_internal::{closure#0}>
2026-09-09T08:22:43.969492Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:544:19
2026-09-09T08:22:43.969494Z 01E 19: std::panic::catch_unwind::<std::rt::lang_start_internal::{closure#0}, isize>
2026-09-09T08:22:43.969496Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panic.rs:359:14
2026-09-09T08:22:43.969498Z 01E 20: std::rt::lang_start_internal
2026-09-09T08:22:43.969500Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/rt.rs:171:5
2026-09-09T08:22:43.969502Z 01E 21: main
2026-09-09T08:22:43.969503Z 01E 22: <unknown>
2026-09-09T08:22:43.969504Z 01E 23: __libc_start_main
2026-09-09T08:22:43.969506Z 01E 24: <unknown>), exit_code: 101 }
2026-09-09T08:22:43.969508Z 01E 2.777976469s DEBUG cargo: display_error; err=No such file or directory (os error 2)
2026-09-09T08:22:43.969510Z 01E
2026-09-09T08:22:43.969511Z 01E Stack backtrace:
2026-09-09T08:22:43.969512Z 01E 0: <anyhow::Error as core::convert::From<gix::submodule::errors::open::Error>>::from
2026-09-09T08:22:43.969514Z 01E 1: cargo::ops::cargo_package::vcs::status_submodules
2026-09-09T08:22:43.969516Z 01E 2: cargo::ops::cargo_package::vcs::status_submodules
2026-09-09T08:22:43.969518Z 01E 3: cargo::ops::cargo_package::vcs::git
2026-09-09T08:22:43.969519Z 01E 4: cargo::ops::cargo_package::do_package
2026-09-09T08:22:43.969521Z 01E 5: cargo::ops::cargo_package::package_with_dep_graph
2026-09-09T08:22:43.969523Z 01E 6: cargo::ops::registry::publish::publish
2026-09-09T08:22:43.969525Z 01E 7: cargo::commands::publish::exec
2026-09-09T08:22:43.969526Z 01E 8: <cargo::cli::Exec>::exec
2026-09-09T08:22:43.969528Z 01E 9: cargo::main
2026-09-09T08:22:43.969529Z 01E 10: std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
2026-09-09T08:22:43.969531Z 01E 11: std::rt::lang_start::<()>::{closure#0}
2026-09-09T08:22:43.969533Z 01E 12: <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once
2026-09-09T08:22:43.969546Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/core/src/ops/function.rs:287:21
2026-09-09T08:22:43.969548Z 01E 13: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
2026-09-09T08:22:43.969551Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:576:43
2026-09-09T08:22:43.969553Z 01E 14: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe>
2026-09-09T08:22:43.969556Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:544:19
2026-09-09T08:22:43.969558Z 01E 15: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
2026-09-09T08:22:43.969561Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panic.rs:359:14
2026-09-09T08:22:43.969563Z 01E 16: std::rt::lang_start_internal::{closure#0}
2026-09-09T08:22:43.969564Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/rt.rs:175:24
2026-09-09T08:22:43.969567Z 01E 17: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize>
2026-09-09T08:22:43.969569Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:576:43
2026-09-09T08:22:43.969571Z 01E 18: std::panicking::catch_unwind::<isize, std::rt::lang_start_internal::{closure#0}>
2026-09-09T08:22:43.969573Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panicking.rs:544:19
2026-09-09T08:22:43.969575Z 01E 19: std::panic::catch_unwind::<std::rt::lang_start_internal::{closure#0}, isize>
2026-09-09T08:22:43.969577Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/panic.rs:359:14
2026-09-09T08:22:43.969579Z 01E 20: std::rt::lang_start_internal
2026-09-09T08:22:43.969581Z 01E at /rustc/88d9e12ae178fab0fb5cc050a94da85685d449ea/library/std/src/rt.rs:171:5
2026-09-09T08:22:43.969583Z 01E 21: main
2026-09-09T08:22:43.969584Z 01E 22: <unknown>
2026-09-09T08:22:43.969585Z 01E 23: __libc_start_main
2026-09-09T08:22:43.969587Z 01E 24: <unknown>
2026-09-09T08:22:43.969588Z 01E error: No such file or directory (os error 2)
My project does contain submodules which are not initialized in the job in which cargo publish runs in.
While I don't directly see a dependency to my submodules for cargo publish, it should not fail in the way it does regardless, since it's not really obvious what's wrong or that it tries to access the submodules.
In the official GitLab CI template for Rust I also don't see any mention in regards to the submodule strategy.
The default Gitlab CI GIT_SUBMODULE_STRATEGY is none, meaning no submodules are initialized.
What I expect to happen is at least some kind of error message that it detected uninitialized submodules or that it ignores the fact that the submodules are not initialized.
Steps
- Setup a cargo project which includes a submodule
- Create a GitLab CI pipeline which uses
cargo publish and uses the default GIT_SUBMODULE_STRATEGY: none
- Run the pipeline and the
cargo publish should fail with error: No such file or directory (os error 2)
Possible Solution(s)
No response
Notes
No response
Version
# cargo version --verbose
cargo 1.98.0 (797e8a9bc 2026-08-05)
release: 1.98.0
commit-hash: 797e8a9bca276c1c9f9f738d2a20f484fa4eea9d
commit-date: 2026-08-05
host: x86_64-unknown-linux-gnu
libgit2: 1.9.4 (sys:0.21.0 vendored)
libcurl: 8.21.0-DEV (sys:0.4.90+curl-8.21.0 vendored ssl:OpenSSL/3.6.3)
ssl: OpenSSL 3.6.3 9 Jun 2026
os: Debian 12.0.0 (bookworm) [64-bit]
Problem
In my GitLab CI Pipeline,
cargo publishfails with:cargo publish --manifest-path share/rust/Cargo.toml --registry myregistry --no-verify --locked --allow-dirty Updating `myregistry` index Updating crates.io index error: No such file or directory (os error 2)Using
CARGO_LOG=trace, I discovered that it fails while doing something git submodule related:My project does contain submodules which are not initialized in the job in which
cargo publishruns in.While I don't directly see a dependency to my submodules for
cargo publish, it should not fail in the way it does regardless, since it's not really obvious what's wrong or that it tries to access the submodules.In the official GitLab CI template for Rust I also don't see any mention in regards to the submodule strategy.
The default Gitlab CI
GIT_SUBMODULE_STRATEGYisnone, meaning no submodules are initialized.What I expect to happen is at least some kind of error message that it detected uninitialized submodules or that it ignores the fact that the submodules are not initialized.
Steps
cargo publishand uses the defaultGIT_SUBMODULE_STRATEGY: nonecargo publishshould fail witherror: No such file or directory (os error 2)Possible Solution(s)
No response
Notes
No response
Version