Skip to content

[BUG] AzureCliCredential fails in non-interactive environments due to hardcoded /bin/sh PATH resolution #47614

@hydraxman

Description

@hydraxman

Describe the bug

When using AzureCliCredential in a non-interactive environment (e.g. IntelliJ IDEA plugin, background service, or other GUI-based Java applications on macOS), authentication fails with:

Exception or Stack Trace
2025-12-30 16:44:26,642 [ 11186] WARN - #com.github.gimhome.aiassistantstats.auth.AuthServiceCompanion - Interactive token acquisition failed com.azure.identity.CredentialUnavailableException: AzureCliCredential authentication unavailable. Azure CLI not installed.To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/java/identity/azclicredential/troubleshoot at com.azure.identity.implementation.IdentityClientBase.getTokenFromAzureCLIAuthentication(IdentityClientBase.java:634) at com.azure.identity.implementation.IdentityClient.authenticateWithAzureCli(IdentityClient.java:318) at com.azure.identity.AzureCliCredential.getToken(AzureCliCredential.java:81) at
-------------------.AuthService
acquireInteractiveToken2.invokeSuspend(AuthService.kt:234) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.internal.SoftLimitedDispatcherWorker.run(SoftLimitedDispatcher.kt:130)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:613)
at kotlinx.coroutines.scheduling.CoroutineSchedulerWorker.executeTask(CoroutineScheduler.kt:1183) at kotlinx.coroutines.scheduling.CoroutineSchedulerWorker.runWorker(CoroutineScheduler.kt:778)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:765)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:104)
at reactor.core.publisher.Mono.block(Mono.java:1779)

To Reproduce

  1. Install Azure CLI on macOS using Homebrew
    (e.g. /usr/local/bin/az or /opt/homebrew/bin/az)
  2. Use AzureCliCredential in a Java application running in a non-interactive / GUI environment
    (e.g. IntelliJ IDEA plugin)
  3. Ensure /bin/sh is invoked without a login shell or user PATH initialization
  4. Call AzureCliCredential.getToken(...)

Code Snippet
Add the code snippet that causes the issue.

Expected behavior

  • correctly locate the Azure CLI executable when it is installed, or
  • provide a clearer error indicating PATH resolution issues

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: MacOS
  • IDE: IntelliJ
  • Library/Libraries: [e.g. com.azure:azure-core:1.16.0 (groupId:artifactId:version)]
  • Java version: [e.g. 8]
  • App Server/Environment: [e.g. Tomcat, WildFly, Azure Function, Apache Spark, Databricks, IDE plugin or anything special]
  • Frameworks: [e.g. Spring Boot, Micronaut, Quarkus, etc]

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions