Skip to content

segfault caused by os.execvpe in windows #84

Open
@matthewdeanmartin

Description

@matthewdeanmartin

I'm using windows 11 and os.execvpe will cause a segfault. I happen to be using gitbash and pipx, but I get the same behavior if I don't use pipx.

After a bit of hacking, I got this to work, but with 2 second additional time cost over using aws directly. I see that 9 month ago execvpe was introduced probably to make things better for linux or mac users

I'm guessing you don't have access to a windows machine, you might want to consider a github action on a windows image to check to see if awslocal --help can run without segfault.

Another possibility is to use something like shellingham to detect the shell before doing things that the OS isn't expected to be able to do.

def run(cmd, env=None):
    """
    Replaces this process with the AWS CLI process, with the given command and environment
    """
    # if not env:
    #     env = {}
    # print("os.execvpe")
    # os.execvpe(cmd[0], cmd, env)
    if env is None:
        env = os.environ.copy()
    else:
        # Make sure we include the current environment to avoid missing essential variables
        full_env = os.environ.copy()
        full_env.update(env)

    print("subprocess.run")
    result = subprocess.run(cmd, env=full_env, text=True, capture_output=True)
    print(result.stdout)  # Print standard output
    print(result.stderr, file=sys.stderr)  # Print standard error to the error stream
    return result

When I use powershell or cmd, I get "ModuleNotFoundError: No module named 'boto3'", probably because the .bat file gets launched and doesn't actual activate the right environment, but I also got that even when installing to the system python (which is a no-no). I didn't pursue why the entry point scripts fail to get an activated environment, since I never use powershell or cmd.exe.

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