localstack / localstack/awscli-local

segfault caused by os.execvpe in windows

Đang mở
#84 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
1.3k
Fork
94
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi trên Windows 11 với awslocal --help và kiểm tra đường dẫn entry point gọi os.execvpe. So sánh hành vi đó với cách tiếp cận subprocess.run được đề xuất và đường dẫn khởi chạy .bat trong PowerShell hoặc cmd. Hoàn tất khi CLI không còn bị segfault trên Windows và entry point của nó chạy trong môi trường dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, python
Lĩnh vực
cli, operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.