Code Monkey home page Code Monkey logo

Comments (8)

uranusjr avatar uranusjr commented on June 19, 2024

Without looking into it too deeply, this is likely caused by a very long file path. Do you have long paths enabled? Can you think of a possible candidate executable that has a very long path in your system? That would help explain the phenomenom.

(This is more a note to self) I think it would likely be sufficient if we just ignore that entry and keep looking. It is highly unlikely the offending process is the shell we are looking for anyway—and we can always deal with it if someone ever needs to detect that process.

from shellingham.

uranusjr avatar uranusjr commented on June 19, 2024

If you want to try whether my guess is correct right now, modify nt.py and change Process32Next like this:

def Process32Next(hSnapshot, pe=None):
    if pe is None:
        pe = PROCESSENTRY32()
    pe.dwSize = sizeof(PROCESSENTRY32)
    success = windll.kernel32.Process32Next(hSnapshot, byref(pe))
    if not success:
        if windll.kernel32.GetLastError() == ERROR_NO_MORE_FILES:
            return
        if windll.kernel32.GetLastError() == 122:  # ERROR_INSUFFICIENT_BUFFER.
            return pe   # If this does not work, try "return".
        raise WinError()
    return pe

and see if that works.

from shellingham.

techalchemy avatar techalchemy commented on June 19, 2024

Seems likely to work ok at a glance, and a good safety measure to build in anyway

from shellingham.

rlshuhart avatar rlshuhart commented on June 19, 2024

Thanks for taking a look! Unfortunately, I might not have a moment to give it a try until next week.

from shellingham.

uranusjr avatar uranusjr commented on June 19, 2024

No hurry, this is not pressing at the moment :)

from shellingham.

rlshuhart avatar rlshuhart commented on June 19, 2024

I edited Process32Next as instructed and success!!!

Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import shellingham
>>> shellingham.detect_shell()
('cmd', 'cmd.exe')

from shellingham.

rlshuhart avatar rlshuhart commented on June 19, 2024

In addition, this was related to attempting to using pipenv shell and having the WinError. Making this same correction in the shellingham used in Pipenv resolved the problem. I suppose Pipenv should be advised to include this correction as well if it passes. Glad to help any anyway, but don't want to overstep.

Before change to .\pipenv\vendor\shellingham\nt.py Process32Next:

Traceback (most recent call last):
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\rshuhart001\AppData\Local\Continuum\anaconda3\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\cli.py", line 664, in shell
    three=three, python=python, fancy=fancy, shell_args=shell_args, pypi_mirror=pypi_mirror
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\core.py", line 2149, in do_shell
    shell = choose_shell()
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\shells.py", line 217, in choose_shell
    type_, command = detect_info()
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\shells.py", line 25, in detect_info
    return shellingham.detect_shell()
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\shellingham\__init__.py", line 24, in detect_shell
    shell = get_shell(pid, max_depth=max_depth)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 117, in get_shell
    processes = get_all_processes()
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 97, in get_all_processes
    pe = Process32Next(h_process, pe)
  File "c:\users\rshuhart001\appdata\local\continuum\anaconda3\lib\site-packages\pipenv\vendor\shellingham\nt.py", line 74, in Process32Next
    raise WinError()
OSError: [WinError 122] The data area passed to a system call is too small.

After change to .\pipenv\vendor\shellingham\nt.py Process32Next:

Launching subshell in virtual environment…
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

(shellingham_test-5dV6dxIr) C:\Users\rshuhart001\Documents\...\Other\shellingham_test>

Ryan

from shellingham.

techalchemy avatar techalchemy commented on June 19, 2024

We maintain pipenv also (this code was written for pipenv and most of the tooling in this organization is for pipenv) so this will land in the next release

from shellingham.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.