Roger-luo / Ion

Ion - a CLI toolbox for Julia developers
https://rogerluo.dev/Ion/
MIT License
65 stars 3 forks source link

`Failed to read command` when attempting `ion summon` #48

Open Krastanov opened 1 year ago

Krastanov commented 1 year ago

I installed ion in a local path, successfully authenticated it to github, successfully used bump but then summon is erroring with error code 101:

stefan@cube ~/D/S/q/QuantumClifford.jl (master) > ion summon
Failed to read command
stefan@cube ~/D/S/q/QuantumClifford.jl (master) [101]> ion -V
ion 0.1.21

Not really sure what to do to debug now

Roger-luo commented 1 year ago

what does it say if you run

RUST_LOG=debug ion summon

also what OS are you on? is this a linux distro?

Krastanov commented 1 year ago
[2023-04-09T21:42:38Z DEBUG ion::config] config file: /home/stefan/.config/ion/config.toml
[2023-04-09T21:42:38Z DEBUG ion::config] config file: true
[2023-04-09T21:42:38Z DEBUG ion::commands::summon] summoning JuliaRegistrator to register /home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl/Project.toml
[2023-04-09T21:42:38Z DEBUG ion::utils::git] get_toplevel_path("/home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl")
[2023-04-09T21:42:38Z DEBUG ion::utils::read_command] Running command: Command {
        program: "git",
        args: [
            "git",
            "rev-parse",
            "--show-toplevel",
        ],
        cwd: Some(
            "/home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl",
        ),
        create_pidfd: false,
    }
[2023-04-09T21:42:39Z DEBUG ion::utils::git] current_branch("/home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl")
[2023-04-09T21:42:39Z DEBUG ion::utils::read_command] Running command: Command {
        program: "git",
        args: [
            "git",
            "rev-parse",
            "--abbrev-ref",
            "HEAD",
        ],
        cwd: Some(
            "/home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl",
        ),
        create_pidfd: false,
    }
[2023-04-09T21:42:39Z DEBUG ion::utils::read_command] Running command: Command {
        program: "git",
        args: [
            "git",
            "symbolic-ref",
            "refs/remotes/origin/HEAD",
        ],
        cwd: Some(
            "/home/stefan/Documents/ScratchSpace/quantumjulia/QuantumClifford.jl",
        ),
        create_pidfd: false,
    }
Failed to read command
Roger-luo commented 1 year ago

It seems the following command doesn't work

git symbolic-ref refs/remotes/origin/HEAD

this command is for getting the current default branch, could you try it locally and see if this fails?

Krastanov commented 1 year ago

This is on Ubuntu 22.04. It is on git 2.37.2

The command indeed fails:

> git symbolic-ref refs/remotes/origin/HEAD
fatal: ref refs/remotes/origin/HEAD is not a symbolic ref

But this issue seems very similar and seems to suggest a workaround https://github.com/jhauberg/gitdoctor/issues/3

> git remote show origin
Host key fingerprint is ...
...
+----[SHA256]-----+
* remote origin
  Fetch URL: git@github.com:Krastanov/QuantumClifford.jl.git
  Push  URL: git@github.com:Krastanov/QuantumClifford.jl.git
  HEAD branch: master
... many more lines of output
Krastanov commented 1 year ago

Or maybe there is some standard way to create refs/remotes/origin/HEAD?

Krastanov commented 1 year ago

Another place where a similar issue has popped up https://github.com/dhimmel/manubot-rootstock/commit/667d170eb2f1898156226456292d25c1c99377c4

Roger-luo commented 1 year ago

So I wrote that because of this StackOverflow post: https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch

Maybe there is a more robust way of detecting the default repo branch in the remote repo, the other way might be using the GitHub API to get the default repo branch, I'm not sure if how it works yet.

Krastanov commented 1 year ago

If I first run git remote set-head origin --auto then git symbolic-ref refs/remotes/origin/HEAD works fine. Could that be enough of a solution?

Roger-luo commented 1 year ago

Hmm, I think I need to understand when refs/remotes/origin/HEAD will appear first and why it might not be there first. But yeah, please use this as a workaround for now until we figure out something more robust.