ValueError: Session requires a `session_id` · Issue #405 · tmux-python/tmuxp · GitHub
Skip to content

ValueError: Session requires a session_id #405

Closed

Description

@vn-ki

I am getting the following error in all configurations. (I tried the config from the readme as well)

Traceback (most recent call last):
  File "/home/vn-ki/.local/bin/tmuxp", line 11, in <module>
    load_entry_point('tmuxp==1.4.0', 'console_scripts', 'tmuxp')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/vn-ki/.local/lib/python3.6/site-packages/tmuxp/cli.py", line 602, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/home/vn-ki/.local/lib/python3.6/site-packages/tmuxp/cli.py", line 328, in load_workspace
    builder.build()
  File "/home/vn-ki/.local/lib/python3.6/site-packages/tmuxp/workspacebuilder.py", line 141, in build
    session_name=self.sconf['session_name']
  File "/home/vn-ki/.local/lib/python3.6/site-packages/libtmux/server.py", line 511, in new_session
    session = Session(server=self, **session)
  File "/home/vn-ki/.local/lib/python3.6/site-packages/libtmux/session.py", line 42, in __init__
    raise ValueError('Session requires a `session_id`')
ValueError: Session requires a `session_id`

Activity

  1. mayanksuman commented on Dec 26, 2018

    @mayanksuman

    The same error occurs for me. I am using following versions of programs/libraries.

    tmuxp 1.4.2
    libtmux 0.8.0
    python 3.6.8
    tmux 2.8

    I have also checked with git master (@03de018) version of tmuxp, the problem still exist.

  2. trodery commented on Mar 22, 2019

    @trodery

    I too had this issue and I took the time to dig a bit deeper into it as I had one environment where I saw the expected (non-broken) behavior and another with the ValueError: Session requires a 'session_id' problem.

    There is command that is ran via subprocess (I believe) which invokes tmux to provide some information in a tab delimited format for parsing. Here's a screenshot showing the command/syntax that is issued to tmux outlined in red:

    image

    This screenshot shows the output that is returned from that command (outlined in red) and as you can see it is not tab delimited.

    image

    The environment that was broken was a docker container, and as it turns out, I had been a bit lazy in its creation and skipped the locale generation part. After properly setting up all the locale and my shell's LANG environment variable to en_US.utf8, everything started working as expected.

    Analyzing the output again in the debugger shows the properly formatted string.
    image

    TL;DR - Check your locale settings and shell LANG variable as the string libtmux is expecting to see when invoking tmux is improperly formatted.

  3. mayanksuman commented on Mar 25, 2019

    @mayanksuman

    @trodery Can you please post the output of locale command in bash. I have tested my locale and LANG variable and they all seem to be fine. Other softwares do not have any issue with my locale setting.

    My locale is set to

    LANG=en_IN
    LANGUAGE=
    LC_CTYPE="en_IN"
    LC_NUMERIC=en_IN.UTF-8
    LC_TIME=en_IN.UTF-8
    LC_COLLATE="en_IN"
    LC_MONETARY=en_IN.UTF-8
    LC_MESSAGES="en_IN"
    LC_PAPER=en_IN.UTF-8
    LC_NAME="en_IN"
    LC_ADDRESS="en_IN"
    LC_TELEPHONE="en_IN"
    LC_MEASUREMENT=en_IN.UTF-8
    LC_IDENTIFICATION="en_IN"
    LC_ALL=
    

    Hence, I suspect that the tmuxp might not support any other English locale except en_US.UTF-8.

  4. trodery commented on Mar 25, 2019

    @trodery

    Here's the output prior to moving to an English locale:

    LANG=
    LANGUAGE=
    LC_CTYPE="POSIX"
    LC_NUMERIC="POSIX"
    LC_TIME="POSIX"
    LC_COLLATE="POSIX"
    LC_MONETARY="POSIX"
    LC_MESSAGES="POSIX"
    LC_PAPER="POSIX"
    LC_NAME="POSIX"
    LC_ADDRESS="POSIX"
    LC_TELEPHONE="POSIX"
    LC_MEASUREMENT="POSIX"
    LC_IDENTIFICATION="POSIX"
    LC_ALL=
    

    The only other problem I experienced was with click which demanded a UTF-8 locale.

  5. rawsp33d commented on Jul 9, 2019

    @rawsp33d

    I have this problem, but didn't used to. The only thing I know of that changed somewhat recently was tmux itself, which is now 2.9a.

  6. sica07 commented on Dec 13, 2019

    @sica07

    I have the very same problem since last evening (after a system update)

  7. trodery commented on Dec 13, 2019

    @trodery

    @sica07 What's the output of the locale command in bash?

  8. tony commented on Dec 15, 2019

    @tony
    Member

    @mayanksuman If it possible to try doing LANG set to en_IN.UTF-8? Can you let me know the session name in unicode? (I guess just pasting it here would be sufficient). As well as python -V, tmux -V and tmuxp -V

    Hence, I suspect that the tmuxp might not support any other English locale except en_US.UTF-8.

    Potentially. I have a feeling it may be click or tmux wanting UTF-8.

    http://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling

    @trodery Can you let me know the session name being used ? As well as python -V, tmux -V and tmuxp -V?

    @rosshadden @sica07 Can you let me know the output of locale, tmux -V, tmuxp -V and python -V?

  9. tony commented on Dec 15, 2019

    @tony
    Member

    @vn-ki Can you show your session yaml file, locale, python -V, tmux -V, tmuxp -V and the command you're using to load the file?

  10. added
    bugSomething isn't working
    on Dec 15, 2019
  11. trodery commented on Dec 17, 2019

    @trodery

    @tony Unfortunately that was so long ago that I don't even remember what I was using it for at the time. It is no longer being used. Python was 3.6 but that's all I remember.

  12. sica07 commented on Dec 19, 2019

    @sica07

    @tony

    $ locale
    LANG=en_US.utf8
    LANGUAGE=en_US.utf8
    LC_CTYPE="en_US.utf8"
    LC_NUMERIC="en_US.utf8"
    LC_TIME="en_US.utf8"
    LC_COLLATE="en_US.utf8"
    LC_MONETARY="en_US.utf8"
    LC_MESSAGES="en_US.utf8"
    LC_PAPER="en_US.utf8"
    LC_NAME="en_US.utf8"
    LC_ADDRESS="en_US.utf8"
    LC_TELEPHONE="en_US.utf8"
    LC_MEASUREMENT="en_US.utf8"
    LC_IDENTIFICATION="en_US.utf8"
    LC_ALL=en_US.utf8
    
     $ python -V
    Python 2.7.13
    
    $ tmuxp -V
    tmuxp 1.5.4
    
  13. added this to the Most requested issues milestone on Feb 29, 2020
  14. em-winterschon commented on Mar 10, 2020

    @em-winterschon

    I ran into the same issue as the original bug report while using tmux 3.0a and tmuxp 1.5.4. Setting the following in ~/.bash_locale and then sourcing it at the end of my .bashrc file resolved the issue.

    I have tmux installed as a compiled binary from the release page source, and tmuxp was installed via pip3, using Python 3.5.2.

    ## Use UTF-8 everywhere                                        
    export LANG=en_US.utf8                                         
    export LANGUAGE=en_US.utf8                                     
    export LC_CTYPE="en_US.utf8"                                   
    export LC_NUMERIC="en_US.utf8"                                 
    export LC_TIME="en_US.utf8"                                    
    export LC_COLLATE="en_US.utf8"                                 
    export LC_MONETARY="en_US.utf8"
    export LC_MESSAGES="en_US.utf8"
    export LC_PAPER="en_US.utf8"                                   
    export LC_NAME="en_US.utf8"                                    
    export LC_ADDRESS="en_US.utf8"                                 
    export LC_TELEPHONE="en_US.utf8"
    export LC_MEASUREMENT="en_US.utf8"
    export LC_IDENTIFICATION="en_US.utf8"
    export LC_ALL=en_US.utf8
    
  15. bjornfor commented on Mar 14, 2020

    @bjornfor

    I know I have some locale issues when running tmuxp from Nixpkgs on Ubuntu, but still think this issue should not happen.

    Here is how it can be reproduced (by setting LC_ALL=C):

    $ cat test.yaml 
    session_name: issue-405
    windows:
    - panes:
        - echo did it load properly or die with a python traceback?
    
    $ LC_ALL=C tmuxp load ./test.yaml
    [...]
    ValueError: Session requires a `session_id`
    
  16. dAnjou commented on Nov 20, 2020

    @dAnjou

    Hi, I'm having the same problem.

    • MacOS 10.15.7
    • iTerm2 3.3.12
    • tmux 3.1c
    • tmuxp 1.6.2
    • zsh 5.8 (x86_64-apple-darwin19.3.0)
    • Python 3.8.6

    locale

    LANG="en_US.utf8"
    LC_COLLATE="C"
    LC_CTYPE="C"
    LC_MESSAGES="C"
    LC_MONETARY="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_ALL="C"
    

    env | grep "^LC"

    LC_TERMINAL_VERSION=3.3.12
    LC_CTYPE=en_US.utf8
    LC_TERMINAL=iTerm2
    LC_ALL=en_US.utf8
    LC_NUMERIC=en_US.utf8
    LC_TIME=en_US.utf8
    LC_COLLATE=en_US.utf8
    LC_MONETARY=en_US.utf8
    LC_MESSAGES=en_US.utf8
    LC_PAPER=en_US.utf8
    LC_NAME=en_US.utf8
    LC_ADDRESS=en_US.utf8
    LC_TELEPHONE=en_US.utf8
    LC_MEASUREMENT=en_US.utf8
    LC_IDENTIFICATION=en_US.utf8
    

    env | grep "^LANG"

    LANG=en_US.utf8
    LANGUAGE=en_US.utf8
    

    Here's a screencast of what is happening:
    tmuxp_session_id

    And here's the code of my script:

    from libtmux import Server
    
    if __name__ == '__main__':
        server = Server()
        if server.has_session("kubernetes-cluster-test"):
            session = server.attach_session("kubernetes-cluster-test")
        else:
            session = server.new_session("kubernetes-cluster-test", attach=True)
        try:
            window = session.select_window("kubernetes-cluster-test")
        except:
            window = session.new_window("kubernetes-cluster-test", attach=True)
        print(window.panes)
  17. Kxrr commented on May 11, 2021

    @Kxrr

    I also encountered this problem, and after debugging, I found that the method libtmux.server.Server._list_sessions uses \t to slice different columns, but in some environments the data returned by proc.stderr is not slice by \t.

    The fix is to change the sliced character to something else, e.g. ||||

  18. grammoboy2 commented on Mar 13, 2022

    @grammoboy2

    Same here:

    Traceback (most recent call last):
    File "/usr/bin/tmuxp", line 33, in
    sys.exit(load_entry_point('tmuxp==1.9.4', 'console_scripts', 'tmuxp')())
    File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in call
    return self.main(*args, **kwargs)
    File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
    File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
    File "/usr/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
    File "/usr/lib/python3.10/site-packages/tmuxp/cli.py", line 1096, in command_load
    load_workspace(config[-1], **tmux_options)
    File "/usr/lib/python3.10/site-packages/tmuxp/cli.py", line 683, in load_workspace
    if builder.session_exists(session_name) and not append:
    File "/usr/lib/python3.10/site-packages/tmuxp/workspacebuilder.py", line 107, in session_exists
    self.session = self.server.find_where({'session_name': session_name})
    File "/usr/lib/python3.10/site-packages/libtmux/common.py", line 316, in find_where
    return self.where(attrs)[0]
    File "/usr/lib/python3.10/site-packages/libtmux/common.py", line 347, in where
    return list(filter(by, self.children))
    File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 185, in sessions
    return self.list_sessions()
    File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 180, in list_sessions
    return [Session(server=self, **s) for s in self._sessions]
    File "/usr/lib/python3.10/site-packages/libtmux/server.py", line 180, in
    return [Session(server=self, **s) for s in self._sessions]
    File "/usr/lib/python3.10/site-packages/libtmux/session.py", line 57, in init
    raise ValueError('Session requires a session_id')
    ValueError: Session requires a session_id

  19. tony commented on Mar 13, 2022

    @tony
    Member

    @grammoboy2 Can you also provide the configuration you're using and tmuxp debug-info

  20. grammoboy2 commented on Mar 14, 2022

    @grammoboy2

    session_name: 3-panes
    windows:

    • window_name: dev window
      layout: main-vertical
      shell_command_before:
      • cd ~/
        panes:
      • shell_command:
        • cd /var/log
        • ls -al | grep .log
      • echo hello
      • echo hello

    debug.txt

  21. tony commented on Mar 14, 2022

    @tony
    Member

    I also encountered this problem, and after debugging, I found that the method libtmux.server.Server._list_sessions uses \t to slice different columns, but in some environments the data returned by proc.stderr is not slice by \t.

    The fix is to change the sliced character to something else, e.g. ||||

    If you use the prerelease version of tmuxp and libtmux, does passing env LIBTMUX_TMUX_FORMAT_SEPARATOR="|||" tmuxp load [session] work?

    pip install --user --upgrade --pre tmuxp libtmux

  22. tony commented on Mar 14, 2022

    @tony
    Member

    @grammoboy2 Thank you

    Output of locale, env | grep "^LC", env | grep "^LANG"

  23. grammoboy2 commented on Mar 14, 2022

    @grammoboy2

    $ locale
    LANG=C
    LC_CTYPE="C"
    LC_NUMERIC="C"
    LC_TIME="C"
    LC_COLLATE="C"
    LC_MONETARY="C"
    LC_MESSAGES="C"
    LC_PAPER="C"
    LC_NAME="C"
    LC_ADDRESS="C"
    LC_TELEPHONE="C"
    LC_MEASUREMENT="C"
    LC_IDENTIFICATION="C"
    LC_ALL=

    $ env | grep "^LC"
    no output

    $ env | grep "^LANG"
    LANG=C

  24. tony commented on Mar 14, 2022

    @tony
    Member

    @grammoboy2 Does setting this work? #405 (comment)

  25. grammoboy2 commented on Mar 14, 2022

    @grammoboy2

    That works, this works too:

    $ unset LANG
    $ source /etc/profile.d/locale.sh

    Note that the session still seems to start when giving that session_id error, cause when I start it after I did the locale thing, it ask to attach to a running session.

    This works in st-term, but in lxterminal, I get strange border characters

  26. grammoboy2 commented on Mar 14, 2022

    @grammoboy2

    lxterminal
    2022-03-14-141536_1342x1046_scrot

  27. tony commented on Mar 14, 2022

    @tony
    Member

    @grammoboy2 I notice its arch. Is this distro fully configured yet? Arch has a lot of manual setup involved. It may be more of a general terminal troubleshooting issue than a tmuxp one. Not sure yet. Maybe its the locale not being setup.

    Does this work?

    I believe instead of LANG=C, LC_CTYPE="C" and so on, you may want to use LANG=en_US.UTF-8.

  28. locked and limited conversation to collaborators on Mar 14, 2022
  29. converted this issue into a discussion #757 on Mar 14, 2022
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

    bugSomething isn't workingpinned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions