Closed monorkin closed 6 years ago
Do you perhaps haver any suspicious global git configuration? This looks like an error coming from libgit2 oddly enough!
None that I am aware of. I know this is a stupid statement, but the same config worked with cargo just a few weeks back.
This is the contents of my .gitconfig
:
[init]
templatedir = ~/.git-templates
[user]
name = Stanko K.R.
email = hey@stanko.io
signingkey = 127A1EEE
[core]
excludesfile = /Users/Stanko/.gitignore_global
editor = nvim
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[credential]
helper = osxkeychain
[push]
default = current
[merge]
tool = nvim
[gpg]
program = gpg2
[commit]
gpgsign = true
[pull]
rebase = true
[alias]
unstage = reset -q HEAD --
discard = checkout --
nevermind = !git reset --hard HEAD && git clean -d -f
uncommit = reset --mixed HEAD~
save = commit -m
resave = commit --amend
invert = revert
last = log -1 HEAD --format=format:"%Cred%H"
summary = status -u -s
graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %ar) %Cred%d' --date-order
history = log -10 --format=format:'%Cgreen%h %Creset• %s (%cN, %ar)'
branchout = checkout -b
tags = tag
branches = branch -a
stashes = stash list
remotes = remote -v
prestage = diff -w --word-diff=color
precommit = diff --cached -w --word-diff=color --word-diff-regex='[^[:space:]<>]+'
move = mv
remove = rm
unmerged = branch --no-merged
unstash = stash pop
what = show -w
untrack = rm -r --cached
rewrite = rebase -i
amend = commit --amend
back = checkout "-"
contributors = shortlog -s -n
filetrail = git log --follow -p -w
mergetrail = log --ancestry-path --merges
unmerged = diff --name-only --diff-filter=U
Hm ok, good to know though! I haven't been able to reproduce this locally, but would you be willing to test this out locally and help poke around? The best way to debug this is probably going to be building a debug build of Cargo (building Cargo locally), and then using that Cargo binary to build your project. You can then execute Cargo in a debugger and place a breakpoint on where this error is being generated from somewhere around here. Once you see an error happening there I'd be curious about the stack trace leading there as well as some of the surrounding variables for why git2 is deducing it should place a temporary file in the root of the filesystem
I've set a breakpoint at git_futils_mktmp
, here is the data you requested.
State of the variables:
(lldb) fr v
(git_buf *) path_out = 0x00007ffeefbe9f20
(const char *) filename = 0x0000000103739d00 "/pack"
(mode_t) mode = 292
(int) fd = -272720160
(mode_t) mask = 0
Value of path_out->ptr
:
(lldb) fr variable path_out->ptr
(char *) path_out->ptr = 0x000000010190f691 ""
Here is the backtrace:
(lldb) thread backtrace
warning: (x86_64) /Users/stanko/Projects/Rust/public/cargo/target/debug/cargo 0x00f8ae05: DW_TAG_member bitfield named "(null)" has invalid bit offset (0x100000000) member will be ignored. Please file a bug against the compiler and include the preprocessed output for /Users/stanko/.cargo/registry/src/github.com-1ecc6299db9ec823/git2-0.7.5/src/lib.rs/@/git2.3hqhl13j-cgu.11
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
warning: (x86_64) /Users/stanko/Projects/Rust/public/cargo/target/debug/cargo 0x00a2a59c: DW_TAG_member bitfield named "(null)" has invalid bit offset (0x100000000) member will be ignored. Please file a bug against the compiler and include the preprocessed output for /Users/stanko/Projects/Rust/public/cargo/src/cargo/lib.rs/@/51jpqh9dw7lsyzgh
warning: (x86_64) /Users/stanko/Projects/Rust/public/cargo/target/debug/cargo 0x00a2a5af: DW_TAG_member bitfield named "(null)" has invalid bit offset (0x100000000) member will be ignored. Please file a bug against the compiler and include the preprocessed output for /Users/stanko/Projects/Rust/public/cargo/src/cargo/lib.rs/@/51jpqh9dw7lsyzgh
warning: (x86_64) /Users/stanko/Projects/Rust/public/cargo/target/debug/cargo 0x00a2a5c2: DW_TAG_member bitfield named "(null)" has invalid bit offset (0x100000000) member will be ignored. Please file a bug against the compiler and include the preprocessed output for /Users/stanko/Projects/Rust/public/cargo/src/cargo/lib.rs/@/51jpqh9dw7lsyzgh
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x0000000100fac689 cargo`git_futils_mktmp(path_out=0x00007ffeefbe9f20, filename="/pack", mode=292) at fileops.c:29
frame #1: 0x0000000100f2e95f cargo`git_indexer_new(out=0x0000000103739da0, prefix=0x0000000000000000, mode=0, odb=0x0000000104e12320, progress_cb=(cargo`git2::remote_callbacks::transfer_progress_cb::heec093ec65aa49c7 at remote_callbacks.rs:304), progress_payload=0x00007ffeefbead80) at indexer.c:136
frame #2: 0x0000000100f61030 cargo`pack_backend__writepack(out=0x00007ffeefbea0d0, _backend=0x0000000104e12540, odb=0x0000000104e12320, progress_cb=(cargo`git2::remote_callbacks::transfer_progress_cb::heec093ec65aa49c7 at remote_callbacks.rs:304), progress_payload=0x00007ffeefbead80) at odb_pack.c:534
frame #3: 0x0000000100f90eab cargo`git_odb_write_pack(out=0x00007ffeefbea0d0, db=0x0000000104e12320, progress_cb=(cargo`git2::remote_callbacks::transfer_progress_cb::heec093ec65aa49c7 at remote_callbacks.rs:304), progress_payload=0x00007ffeefbead80) at odb.c:1483
frame #4: 0x0000000100fc6b98 cargo`git_smart__download_pack(transport=0x00000001070dd800, repo=0x00000001068023a0, stats=0x00000001068480a0, transfer_progress_cb=(cargo`git2::remote_callbacks::transfer_progress_cb::heec093ec65aa49c7 at remote_callbacks.rs:304), progress_payload=0x00007ffeefbead80) at smart_protocol.c:573
frame #5: 0x0000000100f1d1f6 cargo`git_fetch_download_pack(remote=0x0000000106847fd0, callbacks=0x00007ffeefbea5e0) at fetch.c:148
frame #6: 0x0000000100f23ce6 cargo`git_remote_download(remote=0x0000000106847fd0, refspecs=0x00007ffeefbea3f0, opts=0x00007ffeefbea5d8) at remote.c:932
frame #7: 0x0000000100f24176 cargo`git_remote_fetch(remote=0x0000000106847fd0, refspecs=0x00007ffeefbea3f0, opts=0x00007ffeefbea5d8, reflog_message=0x0000000000000000) at remote.c:969
frame #8: 0x0000000100ee86d4 cargo`git2::remote::Remote::fetch::h6aeab226f09a9f69(self=0x00007ffeefbea940, refspecs=&[&str] @ 0x00007ffeefbea398, opts=Option<&mut git2::remote::FetchOptions> @ 0x00007ffeefbea3a8, reflog_msg=Option<&str> @ 0x00007ffeefbea3b0) at remote.rs:224
frame #9: 0x00000001009b508b cargo`cargo::sources::git::utils::fetch::_$u7b$$u7b$closure$u7d$$u7d$::hf52c255d7d1c4025(opts=FetchOptions @ 0x00007ffeefbead78) at utils.rs:723
frame #10: 0x00000001009b4ac9 cargo`cargo::sources::git::utils::with_fetch_options::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h0f92ac83ec83bbfe(f=&mut FnMut<(&str, core::option::Option<&str>, git2::CredentialType)> @ 0x00007ffeefbeac08) at utils.rs:653
frame #11: 0x00000001009b3415 cargo`cargo::sources::git::utils::with_authentication::h63b97651d3731e26(url=(data_ptr = "https://github.com/zacps/winpty", length = 31), cfg=0x00007ffeefbebd60, f=closure @ 0x00007ffeefbeaf88) at utils.rs:450
frame #12: 0x00000001009b4bbb cargo`cargo::sources::git::utils::with_fetch_options::_$u7b$$u7b$closure$u7d$$u7d$::h2f30c31d9e117923 at utils.rs:638
frame #13: 0x00000001009b1ba5 cargo`core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$$u27$a$u20$mut$u20$F$GT$::call_once::h748adf23a1042669(self=0x00007ffeefbeb810, args=<unavailable>) at function.rs:286
frame #14: 0x0000000100b6a971 cargo`cargo::util::network::Retry::try::h0c33eeee95491479(self=0x00007ffeefbeb6a8, f=0x00007ffeefbeb810) at network.rs:25
frame #15: 0x0000000100b6b53e cargo`cargo::util::network::with_retry::hf8fd5da0339bb7f0(config=0x00007ffeefbfe7c0, callback=closure @ 0x00007ffeefbeb810) at network.rs:85
frame #16: 0x0000000100b36a0a cargo`cargo::sources::git::utils::with_fetch_options::hc6ea653229a46d78(git_config=0x00007ffeefbebd60, url=0x0000000104a16800, config=0x00007ffeefbfe7c0, cb=&mut FnMut<(git2::remote::FetchOptions)> @ 0x00007ffeefbeb7b0) at utils.rs:637
frame #17: 0x0000000100b37a6e cargo`cargo::sources::git::utils::fetch::h71bdc67cda31cf9a(repo=0x00007ffeefbec020, url=0x0000000104a16800, refspec=(data_ptr = "refs/heads/*:refs/heads/*src/cargo/sources/git/utils.rsassertion failed: co.is_fresh().cargo-okfetch ", length = 25), config=0x00007ffeefbfe7c0) at utils.rs:709
frame #18: 0x0000000100b31183 cargo`cargo::sources::git::utils::GitRemote::fetch_into::h8248221f57afa29b(self=0x0000000104a16800, dst=0x00007ffeefbec020, cargo_config=0x00007ffeefbfe7c0) at utils.rs:141
frame #19: 0x0000000100b302ba cargo`cargo::sources::git::utils::GitRemote::checkout::h7530c39509780431(self=0x0000000104a16800, into=0x0000000104b85d00, reference=0x0000000104a16858, cargo_config=0x00007ffeefbfe7c0) at utils.rs:103
frame #20: 0x00000001008b3f36 cargo`_$LT$cargo..sources..git..source..GitSource$LT$$u27$cfg$GT$$u20$as$u20$cargo..core..source..Source$GT$::update::h99fff7d2756ac4e5(self=0x0000000104a16800) at source.rs:182
frame #21: 0x0000000100154f78 cargo`cargo::core::registry::PackageRegistry::load::_$u7b$$u7b$closure$u7d$$u7d$::h8c79896831279e5e at registry.rs:305
frame #22: 0x00000001004ee3d7 cargo`cargo::core::registry::PackageRegistry::load::h842644855a08ca7a(self=0x00007ffeefbf4e38, source_id=0x0000000104b9c160, kind=Normal) at registry.rs:293
frame #23: 0x00000001004ec829 cargo`cargo::core::registry::PackageRegistry::ensure_loaded::ha2d8a515bfffab33(self=0x00007ffeefbf4e38, namespace=0x0000000104b9c160, kind=Normal) at registry.rs:137
frame #24: 0x00000001004effe6 cargo`_$LT$cargo..core..registry..PackageRegistry$LT$$u27$cfg$GT$$u20$as$u20$cargo..core..registry..Registry$GT$::query::h90b403e6499cc7b2(self=0x00007ffeefbf4e38, dep=0x00007ffeefbef3e0, f=&mut FnMut<(cargo::core::summary::Summary)> @ 0x00007ffeefbee170, fuzzy=false) at registry.rs:454
frame #25: 0x00000001000efff9 cargo`cargo::core::resolver::types::RegistryQueryer::query::h027433cc03a95611(self=0x00007ffeefbf2430, dep=0x00007ffeefbef3e0) at types.rs:108
frame #26: 0x00000001000d0428 cargo`cargo::core::resolver::context::Context::build_deps::_$u7b$$u7b$closure$u7d$$u7d$::h90a5b2e8653f77d5((null)=<unavailable>) at context.rs:115
frame #27: 0x00000001000d02bf cargo`core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$$u27$a$u20$mut$u20$F$GT$::call_once::h12c2fc974d68a063(self=0x00007ffeefbef9f8, args=((cargo::core::dependency::Dependency, alloc::vec::Vec<cargo::core::interning::InternedString>)) @ 0x00007ffeefbef4d0) at function.rs:286
frame #28: 0x000000010069c368 cargo`_$LT$core..option..Option$LT$T$GT$$GT$::map::ha1e959e33640109a(self=Option<(cargo::core::dependency::Dependency, alloc::vec::Vec<cargo::core::interning::InternedString>)> @ 0x00007ffeefbef620, f=0x00007ffeefbef9f8) at option.rs:414
frame #29: 0x00000001009935cf cargo`_$LT$core..iter..Map$LT$I$C$$u20$F$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$::next::h39a826e8474c7a58(self=0x00007ffeefbef9d8) at mod.rs:1394
frame #30: 0x00000001007a02a9 cargo`_$LT$$LT$core..result..Result$LT$V$C$$u20$E$GT$$u20$as$u20$core..iter..traits..FromIterator$LT$core..result..Result$LT$A$C$$u20$E$GT$$GT$$GT$..from_iter..Adapter$LT$Iter$C$$u20$E$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$::next::h87530aba883a30bf(self=0x00007ffeefbef9d8) at result.rs:1232
frame #31: 0x000000010082872f cargo`_$LT$$RF$$u27$a$u20$mut$u20$I$u20$as$u20$core..iter..iterator..Iterator$GT$::next::he5f9ab3270265ea8(self=0x00007ffeefbef798) at iterator.rs:2562
frame #32: 0x0000000100a83f00 cargo`_$LT$alloc..vec..Vec$LT$T$GT$$GT$::extend_desugared::h4ab6d17890c7c255(self=0x00007ffeefbef8a8, iterator=0x00007ffeefbef9d8) at vec.rs:1980
frame #33: 0x0000000100ad2d7d cargo`_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecExtend$LT$T$C$$u20$I$GT$$GT$::spec_extend::hffa2a8f8d8fca730(self=0x00007ffeefbef8a8, iter=0x00007ffeefbef9d8) at vec.rs:1877
frame #34: 0x0000000100ad8cdd cargo`_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecExtend$LT$T$C$$u20$I$GT$$GT$::from_iter::h530a7139342451c7(iterator=0x00007ffeefbef9d8) at vec.rs:1872
frame #35: 0x0000000100ae5274 cargo`_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..iter..traits..FromIterator$LT$T$GT$$GT$::from_iter::h42022d07a2913149(iter=0x00007ffeefbef9d8) at vec.rs:1772
frame #36: 0x000000010079c8f1 cargo`_$LT$core..result..Result$LT$V$C$$u20$E$GT$$u20$as$u20$core..iter..traits..FromIterator$LT$core..result..Result$LT$A$C$$u20$E$GT$$GT$$GT$::from_iter::hc02f9094aed4a179(iter=<unavailable>) at result.rs:1249
frame #37: 0x00000001009873ca cargo`core::iter::iterator::Iterator::collect::h0b8cb43e85751160(self=<unavailable>) at iterator.rs:1415
frame #38: 0x0000000100638649 cargo`cargo::core::resolver::context::Context::build_deps::h11537275240a5000(self=0x00007ffeefbf2648, registry=0x00007ffeefbf2430, parent=Option<&cargo::core::summary::Summary> @ 0x00007ffeefbefb88, candidate=0x00007ffeefbf00e0, method=0x0000000104a2c2c8) at context.rs:112
frame #39: 0x00000001004e8922 cargo`cargo::core::resolver::activate::hfdf12d836f182dbe(cx=0x00007ffeefbf2648, registry=0x00007ffeefbf2430, parent=Option<(&cargo::core::summary::Summary, &cargo::core::dependency::Dependency)> @ 0x00007ffeefbf0000, candidate=Candidate @ 0x00007ffeefbf0010, method=0x0000000104a2c2c8) at mod.rs:621
frame #40: 0x00000001004e4b8c cargo`cargo::core::resolver::activate_deps_loop::h16b9d1589729562f(cx=Context @ 0x00007ffeefbf2648, registry=0x00007ffeefbf2430, summaries=&[(cargo::core::summary::Summary, cargo::core::resolver::types::Method)] @ 0x00007ffeefbf0b28, config=Option<&cargo::util::config::Config> @ 0x00007ffeefbf0b38) at mod.rs:188
frame #41: 0x00000001004e3840 cargo`cargo::core::resolver::resolve::h8c0b5dc6444d7fc2(summaries=&[(cargo::core::summary::Summary, cargo::core::resolver::types::Method)] @ 0x00007ffeefbf2340, replacements=&[(cargo::core::package_id_spec::PackageIdSpec, cargo::core::dependency::Dependency)] @ 0x00007ffeefbf2350, registry=&mut Registry @ 0x00007ffeefbf2360, try_to_use=0x00007ffeefbf3320, config=Option<&cargo::util::config::Config> @ 0x00007ffeefbf2e10, print_warnings=false) at mod.rs:125
frame #42: 0x000000010085e827 cargo`cargo::ops::resolve::resolve_with_previous::hb912ddfcd9b95546(registry=0x00007ffeefbf4e38, ws=0x00007ffeefbfb938, method=Method @ 0x00007ffeefbf4898, previous=Option<&cargo::core::resolver::resolve::Resolve> @ 0x00007ffeefbf3248, to_avoid=Option<&std::collections::hash::set::HashSet<&cargo::core::package_id::PackageId, std::collections::hash::map::RandomState>> @ 0x00007ffeefbf3250, specs=&[cargo::core::package_id_spec::PackageIdSpec] @ 0x00007ffeefbf3258, register_patches=true, warn=false) at resolve.rs:325
frame #43: 0x000000010085cbee cargo`cargo::ops::resolve::resolve_with_registry::h78d16f6694ab0b6f(ws=0x00007ffeefbfb938, registry=0x00007ffeefbf4e38, warn=false) at resolve.rs:110
frame #44: 0x000000010085b8b7 cargo`cargo::ops::resolve::resolve_ws_with_method::h1b98118ee6661109(ws=0x00007ffeefbfb938, source=Option<alloc::boxed::Box<Source>> @ 0x00007ffeefbf4e18, method=Method @ 0x00007ffeefbf74e8, specs=&[cargo::core::package_id_spec::PackageIdSpec] @ 0x00007ffeefbf4e28) at resolve.rs:62
frame #45: 0x00000001006e459b cargo`cargo::ops::cargo_compile::compile_ws::h3292283a7e64a7ff(ws=0x00007ffeefbfb938, source=Option<alloc::boxed::Box<Source>> @ 0x00007ffeefbf6ec0, options=0x00007ffeefbfbd10, exec=0x00007ffeefbfb828) at cargo_compile.rs:243
frame #46: 0x00000001006e409a cargo`cargo::ops::cargo_compile::compile_with_exec::h69fb7a9da07779dc(ws=0x00007ffeefbfb938, options=0x00007ffeefbfbd10, exec=0x00007ffeefbfb828) at cargo_compile.rs:206
frame #47: 0x00000001006e3f19 cargo`cargo::ops::cargo_compile::compile::hefa2f30a48e0dd8f(ws=0x00007ffeefbfb938, options=0x00007ffeefbfbd10) at cargo_compile.rs:195
frame #48: 0x0000000100086fc0 cargo`cargo::commands::build::exec::h7cca3a9087f56c6f(config=0x00007ffeefbfe7c0, args=0x0000000104a28078) at build.rs:57
frame #49: 0x0000000100021a86 cargo`cargo::cli::execute_subcommand::h92e0e9e2d1cf1fcd(config=0x00007ffeefbfe7c0, args=0x00007ffeefbfe560) at cli.rs:160
frame #50: 0x0000000100020118 cargo`cargo::cli::main::hfc1a3a2fb8035aba(config=0x00007ffeefbfe7c0) at cli.rs:79
frame #51: 0x000000010000adcf cargo`cargo::main::h9dec2188f3229dfa at main.rs:48
frame #52: 0x000000010007ad52 cargo`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h92647073ecdce98c at rt.rs:74
frame #53: 0x0000000101381048 cargo`std::panicking::try::do_call::hcfe6ac53944e0624 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hf8f54988cfbc241e at rt.rs:59 [opt]
frame #54: 0x000000010138103c cargo`std::panicking::try::do_call::hcfe6ac53944e0624 at panicking.rs:310 [opt]
frame #55: 0x00000001013900df cargo`__rust_maybe_catch_panic at lib.rs:103 [opt]
frame #56: 0x0000000101376c4d cargo`std::rt::lang_start_internal::hb972e1f76be57958 [inlined] std::panicking::try::h9432f7e8ae11f605 at panicking.rs:289 [opt]
frame #57: 0x0000000101376c1a cargo`std::rt::lang_start_internal::hb972e1f76be57958 [inlined] std::panic::catch_unwind::haeea9805caae6d4d at panic.rs:392 [opt]
frame #58: 0x0000000101376c1a cargo`std::rt::lang_start_internal::hb972e1f76be57958 at rt.rs:58 [opt]
frame #59: 0x000000010007ad32 cargo`std::rt::lang_start::h12a28ceb5cbbb531(main=(cargo`cargo::main::h9dec2188f3229dfa at main.rs:31), argc=2, argv=0x00007ffeefbff1b8) at rt.rs:74
frame #60: 0x000000010000dc72 cargo`main + 34
frame #61: 0x00007fff78ce4015 libdyld.dylib`start + 1
frame #62: 0x00007fff78ce4015 libdyld.dylib`start + 1
I'll poke around a bit more to find something conclusive.
I think I'm missing something.
The error originates from fileops.c
on line 37
(here), which is in git_futils_mktmp
(as you pointed out).
That function sets the path_out
git_buf to the value of filename
, sufixes it with _git2_XXXXXX
and then tries to create that file through p_mkstemp
.
The input path_out
originates from indexer.c
on line 136
(here) where it's initialized as an empty buffer, and is passed to git_futils_mktmp
on line 162
(here) alongside the path
variable which is converted to a string. The path
variable is also initialized as an empty buffer on the same line and is combined with the prefix
variable and the string /pack
.
The prefix
variable is actually the value of backend->pack_folder
from odb_pack
on line 534
(here). The backend
in turn is created by casting _backend
to pack_backend on line 529
which results in a completely different struct with the parent attribute set to the _backend
variable (I don't know how this happened, I'm guessing it has something to do with the compiler).
This is where the trail ends for me. I'm unsure how casting _backend
to backend
created a new struct with the attribute pack_folder
(which is a NULL pointer). This looks like some class / inheritance like behavior, but we are in C so I don't know where to look for the constructor.
Oh this is just a "trick" of how inheritane is done in C sometimes. The pack_backend
struct starts with git_odb_backend
, which means if you have git_odb_backend*
and you know it's actually a pack_backend*
then you can cast between the two.
I think the pack_folder
variable is probably initialized here, can you perhaps trace backwards from there to see where the empty string comes from?
Oh this is just a "trick" of how inheritane is done in C sometimes. The pack_backend struct starts with git_odb_backend, which means if you have git_odb_backend and you know it's actually a pack_backend then you can cast between the two.
Magic ✨
Just a question, how does git_odb_backend_pack
get called? It seems to me that backend
is declared on line 522 as a pointer of type pack_backend, then the cast occurs on line 529, and the only other reference to backend
is on line 534 where it's passed to git_indexer_new
. It seems to me like backend
, except for the parent attribute, should have all other attributes set to their default values (in this case NULL).
I'll check the git_odb_backend_pack
now.
Ok. That function gets called 3 times.
Once with path /Users/stanko/.cargo/registry/index/github.com-1ecc6299db9ec823/.git/objects/pack
and it passes normally and sets backend->pack_folder
.
Then twice with /Users/stanko/.cargo/git/db/winpty-788a6abf0b1935fd/.git/objects/pack
, but this time it doesn't enter the if statement on line 624
and error
is set to 0
.
I called the two functions manually and got:
(lldb) p git_buf_joinpath((git_buf *)0x00007ffeefbeb650, objects_dir, "pack")
(int) $0 = 0
(lldb) p git_path_isdir(git_buf_cstr((git_buf *)0x00007ffeefbeb650))
(bool) $1 = false
So I guess the git_path_isdir(git_buf_cstr(&path))
is at fault.
I checked on my filesystem and /Users/stanko/.cargo/git/db/winpty-788a6abf0b1935fd/.git/objects/
exists and it's a directory, but /Users/stanko/.cargo/git/db/winpty-788a6abf0b1935fd/.git/objects/pack
doesn't.
Hm ok, I wonder if this is a corrupt git repository then perhaps? If you blow away ~/.cargo/git/db
does the error fix itself?
I tried that when I reinstalled Rust, as I saw that that was the solution to a similar issue, but it didn't help. I tried it again now by running rm -rf ~/.cargo/git/db
and running cargo build
afterwards, sadly to no avail.
Oh wait so actually another thing that's odd is that the paths libgit2 is probing all have .git
in the name, but the folders in ~/.cargo/git/db
should all be bare checkouts. (in that on my system they don't have any .git
folders).
If you look inside of /Users/stanko/.cargo/git/db/winpty-788a6abf0b1935fd/
does it look like a bare git repository? Maybe some local git configuration is accidentally causing libgit2 to get confused about what kind of repo is in use?
It's a mix of my templates directory (which has it's own reposiotry) and the bare git repository. I just removed the templates dir from my gitconfig, reloaded my shell and now everything worked. I must have forgotten to reload my shell when I initially tested this.
Seems like this is a duplicate of another issue where this was the problem also.
Though, this is a regression then. I have used this configuration for well over a year with no issues until now.
Ah ok interesting! Is it possible to narrow down what in your templates directory affects this? Is it the mere presence of templates? The fact that templates are a git repo? One template in particular?
Did a few tests now.
It only fails if inside the templates directory there is a initialized git repository.
If there is an empty .git
directory it still works.
Hm ok interesting! I tried to reproduce that by git init foo
and then setting init.templatedir
to point to that folder, but git dependencies still work for me in Cargo?
Do those steps reproduce for you though?
I just tried to do the same as you and managed to get it to fail. Seems like it can't be an empty repo, it has to have some objects in it.
Steps taken:
vim ~/.gitconfig # removed `templatedir`
exec $SHELL
cd ~/Desktop
mkdir experiment
cd experiment
git init templates
touch templates/THIS_IS_GENERATED_BY_THE_TEMPLATE
cd templates
git add --all
git commit -am 'Foo'
cd ..
vim ~/.gitconfig # added `templatedir = ~/Desktop/experiment/templates`
exec $SHELL
cargo new foo --bin
cd foo
echo "diesel = { git = \"https://github.com/diesel-rs/diesel\" }" >> Cargo.toml
rm -rf ~/.cargo/git
cargo build
Ok cool thanks so much for your help in narrowing this down! I've posted a fix for this at https://github.com/rust-lang/cargo/pull/6252
Thank you for pushing a fix for this :)
I don't know how closed this is, certainly the "reproduction" is still a fact in my Ubuntu 18.04, with a different choice of words
cargo new --bin foobar Created binary (application)
foobarpackage :~$ cd foobar/ :~/foobar$ echo "diesel = { git = \"https://github.com/diesel-rs/diesel\" }" >> Cargo.toml :~/foobar$ cargo build Updating git repository
https://github.com/diesel-rs/diesel error: failed to load source for a dependency on
diesel`
Caused by: Unable to update https://github.com/diesel-rs/diesel
Caused by: failed to clone into: /home/f/.cargo/git/db/diesel-6e3331fb3b9331ec
Caused by: requested file is a directory; class=Invalid (3); code=NotFound (-3) `
I stumbled into this by trying to follow these instructions [https://edgewa.re/lockdrop/gettingstarted.html] . The "bug" seems alive and well with both the curl installation method as well as Ubuntu's package. Creating a new user allowed me to compile the packages, so my default account is somehow tainted, perhaps in a way that proves the fix here was incomplete.
@reppolice It sounds like your issue is different ("NotFound" instead of "Permission denied"). Can you file a new issue, and zip up the contents of /home/f/.cargo/git/db/diesel-6e3331fb3b9331ec
and include it there?
Problem When trying to install a dependency from git I get the following error no matter which project I try to build if it has a git dependency.
Steps
cargo new --bin foobar
cd foobar
echo "diesel = { git = \"https://github.com/diesel-rs/diesel\" }" >> Cargo.toml
cargo build
Possible Solution(s)
By trying to run
cargo
as root it seems likecargo
tries to build git dependencies inside the root directory, which is also indicated by the error as the temporary file is/pack_git2_oFAHxn
. I'm unsure as to why this is happening.Notes
I tried to reinstall Rust but it didn't resolve the issue. I'm able to clone git repositories and use git. I do have a
templatedir
set in my gitconfig (this was indicated to be the problem in a similar issue) but removing it from git, or removing it completely, or removing it from gitconfig didn't solve this issue. I noticed this issue after updating from Rust 1.27 to 1.29, and now on 1.30.Output of
cargo version
:cargo 1.30.0 (36d96825d 2018-10-24)
Output ofrustc --version
:rustc 1.30.0 (da5f414c2 2018-10-24)
Output ofrustup toolchain list
:stable-x86_64-apple-darwin (default)
Output ofgit --version
:git version 2.17.1 (Apple Git-112)
OS: macOS Version 10.13.6 High SierraContents of
~/.cargo
:Output of
printenv
: