withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.05k stars 63 forks source link

bug: Iterm2s 'Reuse previous session's directory' stopped working with fig update #2020

Open ProfChaos opened 1 year ago

ProfChaos commented 1 year ago

Checks

Operating system

MacOS Monterey 12.6

Expected behaviour

Iterm2 opens new window, tab or pane with the same session as the one that was currently active.

So if i'm in ~/work/project and I open new pane I continue from the same directory ~/work/project

Actual behaviour

Iterm2 opens new window, tab or pane always in the home directory.

I'm in ~/work/project and open new pane and ~ is the directory I end up in. Same goes for tab and new window.

Steps to reproduce

With these two lines in .zshrz

[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"

and these two lines in .zprofile

[[ -f "$HOME/.fig/shell/zprofile.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zprofile.pre.zsh"
[[ -f "$HOME/.fig/shell/zprofile.post.zsh" ]] && builtin source "$HOME/.fig/shell/zprofile.post.zsh"

When I remove ALL these lines everything works as normal in iterm, but I can't use fig, obviously

Environment

No response

clo4 commented 1 year ago

CleanShot 2022-11-11 at 10 44 27@2x

That's really strange. I can't reproduce this. Can you run fig diagnostic and send the output?

redjohnzarra commented 1 year ago

CleanShot 2022-11-11 at 10 44 27@2x

That's really strange. I can't reproduce this. Can you run fig diagnostic and send the output?

Same here (Working Directory settings

image

Whenever I open a new tab, it's using the New Window path instead of the previous session's path

fig diagnostic

`fig-details:

ProfChaos commented 1 year ago

https://user-images.githubusercontent.com/814580/201375004-4f0e1d7d-1e66-4023-987f-66fb92812100.mov

fig-details:

AlexVipond commented 1 year ago

I have this issue too, and it gets fixed when I comment out the Fig lines in my .zshrc (I don't use a .zprofile) and open a new iTerm window.

fig diagnostic:

fig-details:
  - 2.13.1-beta.0
hardware-info:
  - model:
  - model-id:
  - chip-id: Apple M1 Max
  - cores: 10
  - mem: 32.00 GB
os-info:
  - macOS 12.6.1 (21G217)
environment:
  - shell: /bin/zsh
  - terminal: iterm
  - cwd: /Users/alexvipond/Code
  - exe-path: /usr/local/bin/fig
  - install-method: unknown
  - env-vars:
    - FIGTERM_SESSION_ID: cf173a4b-10aa-4a95-9ee4-4298dd198b7b
    - FIG_SET_PARENT_CHECK: 1
    - FIG_TERM: 2.13.1-beta.0
    - PATH: /Users/alexvipond/.nvm/versions/node/v19.2.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/alexvipond/.fig/bin:/Users/alexvipond/.local/bin
    - SHELL: /bin/zsh
    - TERM: xterm-256color
    - __CFBundleIdentifier: com.googlecode.iterm2
    - FIG_PID: 40137
    - FIG_SET_PARENT: cf173a4b-10aa-4a95-9ee4-4298dd198b7b
VitaliyR commented 1 year ago

Confirming issue, only full removal of fig helped.

How I've debugged:

  1. Ensured that even that fig is stopped, it still used zsh (figterminal) in processes. Thats weird, I thought if I'd kill the app it wont do it. Obviously removing lines from .zshrc didn't helped as the wrapped terminal was still launched. Idea/improvement:
    • Add option to disable figterm wrapper without uninstalling fig
    • Add option to add lines to .zshenv instead of .zshrc (haven't tested it but I guess fig doctor will complain)
  2. Opened iTerm on home directory, started debug session
  3. Navigated to ~/Work
  4. Wait for 5 seconds
  5. Open split pane/new tab - still on home
  6. Stopped debug session, investigated log entries according to https://github.dev/gnachman/iTerm2

Another run:

  1. Restored window session of iTerm with 5 split panes view in different dirs. Let look on 2 of them - one is pointing at ~/Work/projectA and another is at ~/Work.
  2. Started debug session
  3. Selected pane with ~/Work/projectA and created a new tab -> it landed with ~/Work/projectA - correct.
  4. cd ../ and wait for 5 seconds
  5. Create new pane -> it landed with the same ~/Work/projectA - wrong
  6. Select pane from step 1 with pwd - ~/Work and create new tab - landed on ~/Work - correct. See - it's following current dir from the panes on the first tab - both in this step and in step 3.
  7. cd ../ and wait for 5 seconds
  8. Create new page -> it landed with the same ~/Work - wrong

I went to debug log and found Want working directory of PID and then getWorkingDirectoyrOfProcessWithID returned always wrong directory. PID is matched to the processes of the zsh (figterm). When I've removed fig and have just zsh processes - it returns fine directory.

So I'm assuming that some API call to process not returns directory, so iTerm reuses previously known pwd as lastDirectory or something.

The call: https://github.com/gnachman/iTerm2/blob/b108b4416fc0c12e6198cd8fb33db9a5484d8e6d/sources/iTermPidInfoClient.m#L229

DiegoGiovany commented 1 year ago

Solved !

Vednus commented 1 year ago

@DiegoGiovany how?

alcidesbsilvaneto commented 1 year ago

Still happenning.

sanderbongers commented 1 year ago

Same. Fig doctor says everything looks good. Diagnostics shows environment.cwd as the correct directory.

Some observations:

Hope this helps.

cfsghost commented 1 year ago

any updates?

erikedhagen commented 1 year ago

Also having the same issue, but only on one of my similarly setup computers (M1 Max and M2 Pro). The other works fine.

martinezguillaume commented 1 year ago

Same issue here, after uninstallation of fig, everything works perfect

Issue on my personal & work computer.... very annoying

martinezguillaume commented 1 year ago

it seems that after triggering one time return key with blank entry, it is working as expected It's like the new session is receiving the working directory from the before last directy of the previous session

Sinled commented 9 months ago

Any updates on this? @martinezguillaume trick sometimes works, but would be nice to have this problem solved

Sinled commented 7 months ago

Hack with blank lines stopped working. This is really annoying :(