Skip to content

Commit 5876bf4

Browse files
committed
fix: protect against missing pwd module on Win
1 parent af5156a commit 5876bf4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/structurizr/api/structurizr_client_settings.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""Provide the Structurizr client settings."""
1717

1818

19+
import logging
1920
from getpass import getuser
2021
from pathlib import Path
2122
from socket import getfqdn
@@ -28,7 +29,17 @@
2829
__all__ = ("StructurizrClientSettings",)
2930

3031

31-
USER = getuser()
32+
logger = logging.getLogger(__name__)
33+
34+
35+
try:
36+
USER = getuser()
37+
except ModuleNotFoundError:
38+
logger.error(
39+
"Could not determine the username. Please set it manually or provide a "
40+
"STRUCTURIZR_USER environment variable."
41+
)
42+
USER = "anonymous"
3243
hostname = getfqdn()
3344
if hostname:
3445
USER = f"{USER}@{hostname}"

0 commit comments

Comments
 (0)