localstack / localstack/awscli-local
segfault caused by os.execvpe in windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows 11 failure with awslocal --help and inspect the entry-point path that calls os.execvpe. Compare that behavior with the proposed subprocess.run approach and the .bat launch path in PowerShell or cmd. Done means the CLI no longer segfaults on Windows and its entry point runs in the intended environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100