From af5d139060bbb60690196dc53e05424ac3c0fb5d Mon Sep 17 00:00:00 2001 From: David Knaack Date: Sat, 11 Jan 2025 14:59:29 +0100 Subject: [PATCH] fix(username): avoid using `whoami` on android (#6342) Closes #6340 Co-authored-by: AminurAlam <64137875+aminuralam@users.noreply.github.com> --- src/modules/username.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/username.rs b/src/modules/username.rs index ff38cf69..c25a5bd2 100644 --- a/src/modules/username.rs +++ b/src/modules/username.rs @@ -19,13 +19,13 @@ const USERNAME_ENV_VAR: &str = "USERNAME"; /// Does not display the username: /// - If the option `username.detect_env_vars` is set with a negated environment variable [A] pub fn module<'a>(context: &'a Context) -> Option> { - #[cfg(not(test))] + #[cfg(not(any(test, target_os = "android")))] let mut username = whoami::fallible::username() .inspect_err(|e| log::debug!("Failed to get username {e:?}")) .ok() .or_else(|| context.get_env(USERNAME_ENV_VAR))?; - #[cfg(test)] + #[cfg(any(test, target_os = "android"))] let mut username = context.get_env(USERNAME_ENV_VAR)?; let mut module = context.new_module("username");