jesseduffield / lazygit

simple terminal UI for git commands
MIT License
48.08k stars 1.73k forks source link

lazygit can not works with editor #514

Closed SukkaW closed 4 years ago

SukkaW commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Switch to Commits panel
  2. R to reword commit using editor
+ git rebase --interactive --autostash [hash]

hint: Waiting for your editor to close the file... 2019/09/29 22:34:25 chdir /path/to/.git/rebase-merge/git-rebase-todo: not a directory
error: There was a problem with the editor '/usr/bin/lazygit'.

Press enter to return to lazygit
  1. I have tried both git config --global core.editor $(which vim) and git config --global core.editor $(which nano), neither of them works.

  1. Switch to Commits panel
  2. f to fixup the commit. Enter to confirm.
┌─Error───────────────────────────────────────────────────────────────────────────────────┐
│2019/09/29 22:38:49 chdir /path/to/.git/rebase-merge/git-rebase-todo: not a directory    │
│error: There was a problem with the editor '/usr/bin/lazygit'.                           │
└─────────────────────────────────────────────────────────────────────────────────────────┘
  1. I have tried both git config --global core.editor $(which vim) and git config --global core.editor $(which nano), neither of them works.

Expected behavior A clear and concise description of what you expected to happen.

I use nano as default editor for git. lazygit used to works well with nano.

Desktop (please complete the following information):

$ lazygit -v
commit=95ae806, build date=2019-09-25, build source=debian, version=, os=linux, arch=amd64
SukkaW commented 4 years ago

https://github.com/jesseduffield/lazygit/commit/95ae806e09380e6c1602a91af6d34e8ffd770274

Maybe the issue is related with this commit.

dawidd6 commented 4 years ago

Please try setting EDITOR environment variable and then run lazygit.

Like: EDITOR=vim lazygit.

SukkaW commented 4 years ago

@dawidd6 I have already set EDITOR in my .zshrc.

And if I open lazygit using EDITOR=vim lazygit, the issue still there.

dawidd6 commented 4 years ago

@glvr182 seems like more stuff need tweaking after https://github.com/jesseduffield/lazygit/pull/414

glvr182 commented 4 years ago

Looks as if the env variable does not exist anymore, i'll do some investigating

glvr182 commented 4 years ago

Identified possible bug:

if repoPath != "." {
    if err := os.Chdir(repoPath); err != nil {
        log.Fatal(err.Error())
    }
}

Seems to have side effects

glvr182 commented 4 years ago

When calling a subprocess the program calls lazygit back with the following signature:
lazygit /home/glenn/Develop/src/github.com/jesseduffield/lazygit/.git/rebase-merge/git-rebase-todo This is likely the source of the crash

glvr182 commented 4 years ago

Can you check if #516 works @SukkaW

SukkaW commented 4 years ago

@glvr182

$ git clone https://github.com/glvr182/lazygit
$ cd lazygit
$ git checkout hotfix/path-not-positional
$ go build
$ ./lazygit

And it works.

glvr182 commented 4 years ago

great! PR is up so when that is accepted / merged it should be pushed to the ppa aswell @SukkaW

glvr182 commented 4 years ago

Just to be sure, have you tried overwrtiting the editor aswell?

SukkaW commented 4 years ago

@glvr182 Yeah. I have changed git core.editor config from nano to vim. and lazygit works as expected.

$EDITOR in shell enviroment is not effective for lazygit even if I have removed git core.editor config. But I believe it is expected behavior: lazygit should use value from git config core.editor only.

dawidd6 commented 4 years ago

lazygit should fallback to EDITOR if git.editor is not set