Skip to content

new-window -c resolves symlinks #3186

Closed

Description

@dlukes

Issue description

With the following directory layout...

mkdir foo
ln -s foo bar

... if I run the tmux commnad new-window -c bar, I end up in foo anyway (the symlink gets resolved). Same with split-window.

Is this intentional? Or can it be avoided? I'd like to keep the symlinked path if at all possible.

I know tmux can't keep track of the symlinked path on its own (#1282), but I thought if I provided it explicitly, it would honor it?

Required information

Activity

  1. nicm commented on May 13, 2022

    @nicm
    Member

    The kernel only stores the resolved path. We used to set PWD as well so the shell would have the original path, but that doesn't seem to be there anymore. I'll have to figure out if it was removed by mistake or if there was a reason.

  2. dlukes commented on May 13, 2022

    @dlukes
    Author

    Thanks for looking into this!

    The kernel only stores the resolved path.

    I was a bit confused by this at first -- what does it matter what the kernel stores, if I provide the path manually? -- but then I realized tmux probably does something akin to this...

    import os
    os.chdir("bar")
    os.execl("/bin/bash", "/bin/bash")

    ... and that also lands me in foo, even though I asked for bar. Because how else would I inform an arbitrary process about the current working directory, other than having inherit it via what the kernel says it is. Thanks for making that clearer in my mind.

  3. nicm commented on May 14, 2022

    @nicm
    Member

    I think the PWD change was lost in the merge of the spawn.c change, so I think we can add it back, please try this: x.diff.txt

  4. dlukes commented on May 14, 2022

    @dlukes
    Author

    Thank you for the quick response! The patch fixes the issue, but only partially -- as long as I provide an absolute path. So new-window -c /absolute/path/to/bar lands me in bar, but new-window -c relative/path/to/bar still lands me in foo. Is that expected?

  5. danjenson commented on May 14, 2022

    @danjenson

    I'm also seeing problems with -c not being respected at all in tmux3.2a, using nushell 0.62.0

  6. dlukes commented on May 15, 2022

    @dlukes
    Author

    @danjenson Having read through nushell/nushell#5050, that seems to be an issue with nushell failing to communicate the working directory in a standard way. Not only tmux is affected, but Tilix and other terminal emulators too. And conversely, other shells work perfectly fine in all of these.

    So I don't think it's a tmux issue, or related to what we're discussing here.

    but new-window -c relative/path/to/bar still lands me in foo. Is that expected?

    I guess for that to work, tmux would first have to read PWD from the shell's environment and set the path relative to that?

  7. added a commit that references this issue on May 15, 2022
  8. nicm commented on May 17, 2022

    @nicm
    Member

    Try this to do relative paths please: y.diff.txt

  9. dlukes commented on May 17, 2022

    @dlukes
    Author

    That works like a charm, thank you very much!

  10. nicm commented on May 20, 2022

    @nicm
    Member

    Applied now, thanks!

  11. github-actions commented on Jun 20, 2022

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked as resolved and limited conversation to collaborators on Jun 20, 2022
  13. nicm commented on Oct 11, 2022

    @nicm
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions