7

Just as the title says, whenever I try to start tmux in Cygwin 64-bit (Win7), with any or no arguments besides --help, I get the following error:

$ tmux
failed to connect to server: No error

I can't reproduce this on Linux. Any help would be greatly appreciated.

Thanks!

5 Answers 5

6

This works for me too on 32-bit Win7. But I need to delete the directory every time before launching tmux so I just added an alias to .bashrc.

alias tmux='rm -rf /tmp/tmux* && tmux'
1
  • It seems that cygwin does not always use /tmp for the temp directory. My temp directory was /cygdrive/c/Users/<username>/AppData/Local/Temp/tmux-1000/ and saved in a few different variables: $TMPDIR, $temp, and $tmp. I'm not sure which one tmux was actually using, but if this answer doesn't work for someone out there, check these variables to see if tmux is storing its working dir somewhere else.
    – Matthew
    Jul 15, 2014 at 4:13
4

The alias method suggested by bender doesn't really work if you're trying to reattach, because it kills the existing session(s). The following seems to have solved the problem for me:

  1. Save the Perl script at http://pastebin.com/nN6zX37K to "~/bin/tmux" or elsewhere in your path, ahead of /usr/bin.

  2. Give it execute permissions: "chmod +x ~/bin/tmux".

  3. Exit and reopen Cygwin.

  4. Run tmux commands normally.

This works because it detects the state where tmux has closed entirely but did not remove its temporary directory, which it solves by removing the temp directory (as suggested by bender), but then runs the desired command.

2

try command strace -f -o strace.out tmux new and then check file strace.out for possible reasons. I had the same error and deleted folder /tmp/tmux-XXXXX it had incorrect permissions.

1
  • Thank you!! The strace showed me that tmux was creating its temp directory in /cygdrive/c/Users/<username>/AppData/Local/Temp/tmux-1000/ instead of /tmp where it seems to be for other people here. After I deleted that directory tmux was able to start normally.
    – Matthew
    Jul 15, 2014 at 4:08
2

Many of the solutions to just remove the tmux files in /tmp will break reattaching to a detached session if tmux is actually working.

This solution similar to the perl solution, in that it has some guards before removing stuff in /tmp, but is implemented in bash.

Add this to your ~/.bashrc

tmux() {
  local tmux_cmd
  if ! tmux_cmd=$(which tmux); then
    echo "error: tmux not installed" >&2
    return 1
  fi
  if ! $tmux_cmd ls > /dev/null 2>&1; then
    # tmux ls returned error, so lets try cleaning up /tmp
    /bin/rm -rf /tmp/tmux*
  fi
  $tmux_cmd "$@"
}
1
  • you can also delete the files, and SIGUSR1 the tmux process to have it recreate the tmux-XXXXX/default socket. Mar 3, 2017 at 15:17
-1

just remove /tmp/tmux-* folder on startup:

cat rm -r /tmp/tmux-* >> ~/.bashrc

1
  • 2
    Please elaborate in the answer why this would solve the problem. In addition, the command does not actually work. You probably would want to use echo with single quotes.
    – mtak
    Jun 13, 2014 at 10:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .