Skip to content

Solaris failures from pipenv #25

Description

@philkav

Hi, I've hit an issue on Solaris 11.4 when trying to invoke a shell using pipenv version 2018.11.26 (python3.7)

Similar to:
detect_shell fails on IBM i / AIX #21

The messages I would see were like so:

host# pipenv shell
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 6, in <module>
    from pipenv import cli
  File "/usr/local/lib/python3.7/site-packages/pipenv/__init__.py", line 47, in <module>
    from .cli import cli
  File "/usr/local/lib/python3.7/site-packages/pipenv/cli/__init__.py", line 3, in <module>
    from .command import cli
  File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 7, in <module>
    import crayons
  File "/usr/local/lib/python3.7/site-packages/pipenv/patched/crayons.py", line 49, in <module>
    is_powershell = "powershell" in shellingham.detect_shell()[0]
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/__init__.py", line 22, in detect_shell
    shell = get_shell(pid, max_depth=max_depth)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/posix/__init__.py", line 54, in get_shell
    mapping = _get_process_mapping()
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/posix/__init__.py", line 15, in _get_process_mapping
    mapping = impl.get_process_mapping()
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/posix/proc.py", line 64, in get_process_mapping
    tty, ppid = _get_stat(pid, stat_name)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/posix/proc.py", line 36, in _get_stat
    return parts[STAT_TTY], parts[STAT_PPID]
IndexError: list index out of range

The real issue here is that when shellingham tries to split the data it reads from /proc/PID/status, it fails, because the formatting is not as it expected.

In order to get around this, I modified posix/proc.py like so:

--- proc.py     Mon Sep  9 17:31:45 2019
+++ /usr/local/lib/python3.7/site-packages/pipenv/vendor/shellingham/posix/proc.py      Mon Sep  9 17:25:12 2019
@@ -4,6 +4,7 @@
 import sys
 
 from ._core import Process
+from .._core import ShellDetectionFailure
 
 
 STAT_PPID = 3
@@ -33,7 +34,10 @@
     with io.open(path, encoding='ascii', errors='replace') as f:
         # We only care about TTY and PPID -- all numbers.
         parts = STAT_PATTERN.findall(f.read())
-        return parts[STAT_TTY], parts[STAT_PPID]
+        try:
+            return parts[STAT_TTY], parts[STAT_PPID]
+        except IndexError:
+            raise ShellDetectionFailure
 

This solved the failures on my end.

Perhaps this is already fixed by 'Switch to parse 'ps wwl' for better compatibility #23'.
I can test this if necessary.

Activity

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