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

Error getting latest version for python: git failed #2962

Open
KyleKing opened this issue Nov 7, 2024 · 10 comments
Open

Error getting latest version for python: git failed #2962

KyleKing opened this issue Nov 7, 2024 · 10 comments
Labels

Comments

@KyleKing
Copy link

KyleKing commented Nov 7, 2024

Describe the bug

After updating to mise 2024.11.4, I've started seeing the below error on mise ls, mise doctor, etc.

To Reproduce

brew upgrade mise

And run commands that require the Python checkout:

> mise up
mise WARN  Error getting latest version for python: git failed: Cmd(["git", "-C", "/Users/kyleking/Library/Caches/mise/python/pyenv", "-c", "safe.directory=/Users/kyleking/Library/Caches/mise/python/pyenv", "fetch", "--prune", "--update-head-ok", "origin", "master:master"]) fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

mise doctor output

> mise doctor
version: 2024.11.4 macos-arm64 (2024-11-06)
activated: yes
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS
  Built: Wed, 6 Nov 2024 22:16:42 +0000
  Rust Version: rustc 1.82.0 (f6e511eec 2024-10-15) (Homebrew)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (arm64-apple-darwin24.0)

dirs:
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/Library/Caches/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files:
  ~/.tool-versions
  ~/.config/mise/config.toml

backends:
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:
The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value:
   0: git failed: Cmd(["git", "-C", "/Users/kyleking/Library/Caches/mise/python/pyenv", "-c", "safe.directory=/Users/kyleking/Library/Caches/mise/python/pyenv", "fetch", "--prune", "--update-head-ok", "origin", "master:master"]) fatal: 'origin' does not appear to be a git repository
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.
   0:

Location:
   src/git.rs:74

Additional context

stderr from above mise doctor with RUST_BACKTRACE=full

The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value:
   0: git failed: Cmd(["git", "-C", "/Users/kyleking/Library/Caches/mise/python/pyenv", "-c", "safe.directory=/Users/kyleking/Library/Caches/mise/python/pyenv", "fetch", "--prune", "--update-head-ok", "origin", "master:master"]) fatal: 'origin' does not appear to be a git repository
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.
   0:

Location:
   src/git.rs:74

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 4 frames hidden ⋮
   5: mise::git::Git::update::{{closure}}::h6b55749d187fe561
      at <unknown source file>:<unknown line>
   6: mise::git::Git::update::he2dd0884e599d23e
      at <unknown source file>:<unknown line>
   7: std::sys::backtrace::__rust_begin_short_backtrace::hf906e4a804668876
      at <unknown source file>:<unknown line>
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}::h5ccc1b14c06389f0
      at <unknown source file>:<unknown line>
   9: std::sys::pal::unix::thread::Thread::new::thread_start::h9e79a8d54639c27f
      at <unknown source file>:<unknown line>
  10: __pthread_deallocate<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Location: src/toolset/mod.rs:288

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 9 frames hidden ⋮
  10: <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::try_fold::ha99263d1c24274ba
      at <unknown source file>:<unknown line>
  11: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter::h28b6b83b04b7b1cf
      at <unknown source file>:<unknown line>
  12: core::iter::adapters::try_process::h8fd80cc5ad36691c
      at <unknown source file>:<unknown line>
  13: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::hf669556068c7303a
      at <unknown source file>:<unknown line>
  14: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend::h998de4cac3b4a039
      at <unknown source file>:<unknown line>
  15: rayon::iter::plumbing::bridge_producer_consumer::helper::hb860efbcfc334299
      at <unknown source file>:<unknown line>
  16: rayon_core::join::join_context::{{closure}}::hbfafed8263d9b618
      at <unknown source file>:<unknown line>
  17: rayon::iter::plumbing::bridge_producer_consumer::helper::hb860efbcfc334299
      at <unknown source file>:<unknown line>
  18: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::he9604c6d44222a7a
      at <unknown source file>:<unknown line>
  19: rayon_core::registry::WorkerThread::wait_until_cold::hb8d80409e54f2d72
      at <unknown source file>:<unknown line>
  20: rayon_core::registry::ThreadBuilder::run::ha798e54870547d13
      at <unknown source file>:<unknown line>
  21: std::sys::backtrace::__rust_begin_short_backtrace::hab24813a0d014675
      at <unknown source file>:<unknown line>
  22: core::ops::function::FnOnce::call_once{{vtable.shim}}::hd369b589a0def31b
      at <unknown source file>:<unknown line>
  23: std::sys::pal::unix::thread::Thread::new::thread_start::h9e79a8d54639c27f
      at <unknown source file>:<unknown line>
  24: __pthread_deallocate<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
@KyleKing KyleKing added the bug label Nov 7, 2024
@KyleKing
Copy link
Author

KyleKing commented Nov 7, 2024

Appears to be fixed with:

rm -r ~/Library/Caches/mise/python/pyenv

And running any mise command, such as mise up

@KyleKing KyleKing closed this as completed Nov 7, 2024
@Aeron
Copy link

Aeron commented Dec 2, 2024

The same solution works for the following warning:

mise WARN  Error getting latest version for python: remote 'origin' does not exist; class=Config (7); code=NotFound (-3)
Nothing to update.

I’m posting it here for those looking for the same problem and for historical consistency.

Yet I don’t think it’s a good UX to expect users to know it’s a whole Pyenv repo cached somewhere underneath, often responsible for Python update hiccups. So, if we rely on the 3rd-party repo, should we consider Mise cleaning it occasionally then? But I’m not sure it’s enough of a suggestion for a separate feature request since “automagically” is never simple.

@jdx
Copy link
Owner

jdx commented Dec 2, 2024

Error getting latest version for python: remote 'origin' does not exist

the question is why is this happening. I don't know. If we could figure that out we could probably fix it. I'm certainly not in favor of just deleting it if it misbehaves. That's a good debugging step. It's not a good thing for mise to do it automatically.

should we consider Mise cleaning it occasionally

I mean, if the issue is a missing remote we could probably fix it by adding the the remote without resorting to something so drastic

@hit0ri
Copy link

hit0ri commented Dec 26, 2024

Got the same message as a warning on mise up.
Running the command inside the pyenv repo reveals that it doesn't have any remotes.

❯ git fetch --prune --update-head-ok origin master:master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
❯ git remote -v
❯ 
❯ ls .git
FETCH_HEAD  HEAD  hooks  index  info  logs  objects  refs

@xremming
Copy link

I have this issue happening quite often. It seems that pyenv gets broken somewhat easily?

@coffee-cup
Copy link

coffee-cup commented Jan 30, 2025

I've noticed this happening when I try to get the latest python version in multiple processes/terminal tabs.

I am seeing this error

failed to run mise command '/tmp/mise/mise-2025.1.15 latest --verbose [email protected]': exit status 1
stdout: 
stderr: DEBUG ARGS: /tmp/mise/mise-2025.1.15 latest --verbose [email protected]
DEBUG Installing python-build to /home/runner/.cache/mise/python/pyenv
DEBUG cloning https://github.com/pyenv/pyenv.git to /home/runner/.cache/mise/python/pyenv
DEBUG starting new connection: https://github.com/
Error: 
   0: Failed to update references to their new position to match their remote locations
   1: The packed-ref transaction could not be committed
   2: Changes to the resource could not be committed
   3: No such file or directory (os error 2)

Location:
   src/git.rs:127

Version:
   2025.1.15 linux-x[64]

I (think) I've fixed it by falling back to the git CLI by setting the MISE_LIBGIT2=false and MISE_GIX=false environment variables. (ref)

@KyleKing KyleKing reopened this Jan 30, 2025
@kylejb
Copy link

kylejb commented Jan 30, 2025

Appears to be fixed with:

rm -r ~/Library/Caches/mise/python/pyenv

And running any mise command, such as mise up

I had to remove ~/.cache/mise/python/pyenv instead, which seems to resolve the error... for now at least.

@jdx
Copy link
Owner

jdx commented Jan 30, 2025

it could probably be fixed by adding a LockFile: https://github.com/jdx/mise/blob/main/src/lock_file.rs

like we do for erlang:

fn lock_build_tool(&self) -> Result<fslock::LockFile> {
LockFile::new(&self.kerl_path())
.with_callback(|l| {
trace!("install_or_update_kerl {}", l.display());
})
.lock()
}
fn update_kerl(&self) -> Result<()> {
let _lock = self.lock_build_tool();

@kylejb
Copy link

kylejb commented Jan 30, 2025

it could probably be fixed by adding a LockFile: https://github.com/jdx/mise/blob/main/src/lock_file.rs

I'm not super familiar with your codebase yet, but it sounds reasonable to me. Seems as though it would at least prevent the error from occurring. Does this mean the root cause relates to upstream dependencies (e.g., build tools such as pipenv)?

@failable
Copy link

failable commented Feb 3, 2025

Same issue after I switched to fish shell today. I don't even use mise to manage my Pythons. But every directory containing .python-version causes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants