localstack / localstack/awscli-local

segfault caused by os.execvpe in windows

Abierto
#84 13 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
1.3k
Forks
94
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo el fallo en Windows 11 con awslocal --help e inspecciona la ruta del entry point que llama a os.execvpe. Compara ese comportamiento con el enfoque propuesto de subprocess.run y con la ruta de lanzamiento .bat en PowerShell o cmd. La tarea está terminada cuando la CLI ya no produce un error de segmentación en Windows y su entry point se ejecuta en el entorno previsto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, python
Área
cli, operating-systems
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.