Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Check skill install path ancestors

Laith Weinbergerd5338ec2084e
diff --git a/browser_use/skill_cli/commands/skill.py b/browser_use/skill_cli/commands/skill.py
index adad84111..30bec2a0f 100644
--- a/browser_use/skill_cli/commands/skill.py
+++ b/browser_use/skill_cli/commands/skill.py
@@ -112,8 +112,13 @@ def _validate_output_paths(output_paths: list[Path]) -> None:
for output_path in output_paths:
if output_path.exists() and output_path.is_dir():
raise RuntimeError(f'{output_path} is a directory, expected a SKILL.md file path.')
- if output_path.parent.exists() and not output_path.parent.is_dir():
- raise RuntimeError(f'{output_path.parent} is not a directory.')
+ ancestor = output_path.parent
+ while not ancestor.exists():
+ if ancestor.parent == ancestor:
+ break
+ ancestor = ancestor.parent
+ if ancestor.exists() and not ancestor.is_dir():
+ raise RuntimeError(f'{ancestor} is not a directory.')
def handle(argv: list[str]) -> int:
diff --git a/tests/ci/test_browser_use_skill_install_docs.py b/tests/ci/test_browser_use_skill_install_docs.py
index 6e233b8bc..12b118412 100644
--- a/tests/ci/test_browser_use_skill_install_docs.py
+++ b/tests/ci/test_browser_use_skill_install_docs.py
@@ -133,7 +133,7 @@ def test_browser_use_skill_cli_validates_destination_before_installing_harness(t
env['UV_TOOL_INSTALL_ARGS_FILE'] = str(uv_args)
result = subprocess.run(
- [sys.executable, '-m', 'browser_use.skill_cli.main', 'skill', 'install', '--path', str(blocking_file)],
+ [sys.executable, '-m', 'browser_use.skill_cli.main', 'skill', 'install', '--path', str(blocking_file / 'nested')],
cwd=ROOT,
env=env,
capture_output=True,