Skip to content

Conversation

lorenzofavaro
Copy link

@lorenzofavaro lorenzofavaro commented Aug 17, 2025

Description

Fixes issues #6 and #1785 where ADK commands crash on Windows due to symlink creation requiring admin privileges.

Problem

On Windows, running ADK commands (like adk run) fails with OSError: [WinError 1314] A required privilege is not held by the client: ... because the logging system attempts to create a symlink for the latest log file. Windows requires administrator privileges for symlink creation by default (unless Developer Mode is enabled), causing crashes for non-admin users.

Root Cause

The issue was in logs.py where os.symlink() was called unconditionally without error handling, causing the entire CLI to crash when symlink creation failed.

Solution

This PR implements graceful symlink handling. Changes made:

  • Extracted symlink creation into separate function with error handling
  • Added graceful fallback when symlink creation fails
  • Replaced crashes with warnings to keep CLI functional
  • Improved user messaging about log file locations

This solution follows a similar pattern to the one used in ROS2 in its logging module.

Testing

Before (broken)

> adk run my_agent
Log setup complete: C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215119.log
Traceback (most recent call last):
  File "google\adk\cli\utils\logs.py", line 72, in log_to_tmp_folder
    os.symlink(log_filepath, latest_log_link)
OSError: [WinError 1314] A required privilege is not held by the client

After (fixed)

> adk run my_agent
Log setup complete: C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215319.log
UserWarning: Cannot create symlink for latest log file: [WinError 1314] A required privilege is not held by the client
To access latest log: tail -F C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215319.log
Running agent my_agent, type exit to exit.

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools labels Aug 17, 2025
@adk-bot adk-bot requested a review from seanzhou1023 August 17, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants