Skip to content

Commit

Permalink
fix: add warning for cases when explore is used within wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Aug 1, 2024
1 parent 2b00e3d commit c1703d8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/algokit/cli/explore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import functools
import logging
import os
import platform
from typing import TypedDict
from urllib.parse import urlencode

Expand All @@ -10,6 +12,21 @@
logger = logging.getLogger(__name__)


@functools.cache
def _is_wsl(v: str = platform.uname().release) -> int:
"""
detects if Python is running in WSL
https://github.com/scivision/detect-windows-subsystem-for-linux
"""

if v.endswith("-Microsoft"):
return 1
elif v.endswith("microsoft-standard-WSL2"):
return 2

return 0


class NetworkConfigurationRequired(TypedDict):
algod_url: str
indexer_url: str
Expand Down Expand Up @@ -98,4 +115,9 @@ def get_explore_url(network: str) -> str:
def explore_command(network: str) -> None:
url = get_explore_url(network)
logger.info(f"Opening {network} explorer in your default browser")
if _is_wsl():
logger.warning(
"WSL detected. Make sure that wslu is installed in order for the cli to open browsers in host OS. "
"Installation instructions: https://wslutiliti.es/wslu/install.html"
)
click.launch(url)

0 comments on commit c1703d8

Please sign in to comment.