Skip to content

Commit

Permalink
Merge pull request containers#317 from containers/podman-machine-check
Browse files Browse the repository at this point in the history
Check if podman machine is running before attempting to run
  • Loading branch information
ericcurtin authored Oct 16, 2024
2 parents cb078ed + 00cef7f commit 54b8ec8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ def ai_support_in_vm(conman):
return False

if conman == "podman":
podman_machine_list = ["podman", "machine", "list"]
conman_args = [conman, "machine", "list", "--format", "{{ .VMType }}"]
try:
output = run_cmd(podman_machine_list).stdout.decode("utf-8").strip()
if "running" not in output:
return False

output = run_cmd(conman_args).stdout.decode("utf-8").strip()
if output == "krunkit" or output == "libkrun":
return True

except subprocess.CalledProcessError:
pass

Expand All @@ -59,11 +65,6 @@ def use_container():
if sys.platform == "darwin":
conman = container_manager()
krunkit_configured = ai_support_in_vm(conman)
if krunkit_configured:
print(f"Running in a container via {conman}")
else:
print("Running natively on macOS")

return krunkit_configured

return True
Expand Down

0 comments on commit 54b8ec8

Please sign in to comment.