From 2c6e22e74639ae78c01ee3d59f244a3ce11150d3 Mon Sep 17 00:00:00 2001 From: Aditya Advani Date: Thu, 5 Mar 2026 20:05:11 +0000 Subject: [PATCH 1/2] fix(dev-install): resolve OpenClaw CLI entrypoint path dynamically --- roles/openclaw/tasks/openclaw-development.yml | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/roles/openclaw/tasks/openclaw-development.yml b/roles/openclaw/tasks/openclaw-development.yml index 653c345..0c009e5 100644 --- a/roles/openclaw/tasks/openclaw-development.yml +++ b/roles/openclaw/tasks/openclaw-development.yml @@ -83,6 +83,28 @@ msg: "Build failed - dist directory not found" when: not dist_dir.stat.exists +- name: Resolve openclaw CLI entrypoint path + ansible.builtin.shell: + cmd: | + set -euo pipefail + for rel in openclaw.mjs bin/openclaw.js dist/index.js; do + if [ -f "{{ openclaw_repo_dir }}/$rel" ]; then + printf '%s\n' "{{ openclaw_repo_dir }}/$rel" + exit 0 + fi + done + exit 1 + executable: /bin/bash + register: openclaw_cli_entry + changed_when: false + +- name: Fail if openclaw CLI entrypoint is missing + ansible.builtin.fail: + msg: >- + Unable to locate OpenClaw CLI entrypoint in {{ openclaw_repo_dir }}. + Expected one of: openclaw.mjs, bin/openclaw.js, dist/index.js + when: (openclaw_cli_entry.stdout | trim) == "" + - name: Remove existing global openclaw symlink (if any) ansible.builtin.file: path: "{{ openclaw_home }}/.local/bin/openclaw" @@ -90,7 +112,7 @@ - name: Create symlink to openclaw binary ansible.builtin.file: - src: "{{ openclaw_repo_dir }}/bin/openclaw.js" + src: "{{ openclaw_cli_entry.stdout | trim }}" dest: "{{ openclaw_home }}/.local/bin/openclaw" state: link owner: "{{ openclaw_user }}" @@ -99,7 +121,7 @@ - name: Make openclaw binary executable ansible.builtin.file: - path: "{{ openclaw_repo_dir }}/bin/openclaw.js" + path: "{{ openclaw_cli_entry.stdout | trim }}" mode: '0755' owner: "{{ openclaw_user }}" group: "{{ openclaw_user }}" @@ -122,7 +144,7 @@ msg: | OpenClaw installed from source: {{ openclaw_dev_version.stdout }} Repository: {{ openclaw_repo_dir }} - Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_repo_dir }}/bin/openclaw.js + Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_cli_entry.stdout | trim }} - name: Add development mode info to .bashrc ansible.builtin.blockinfile: From 4cc27b4993e7fdb2f7f80cfda3e1f45d7c3b88db Mon Sep 17 00:00:00 2001 From: Andy Lauppe Date: Wed, 11 Mar 2026 00:25:31 -0400 Subject: [PATCH 2/2] fix(dev-install): resolve CLI entrypoint from metadata with fallbacks Co-authored-by: Aditya Advani --- roles/openclaw/tasks/openclaw-development.yml | 87 +++++++++++++++---- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/roles/openclaw/tasks/openclaw-development.yml b/roles/openclaw/tasks/openclaw-development.yml index 0c009e5..baad419 100644 --- a/roles/openclaw/tasks/openclaw-development.yml +++ b/roles/openclaw/tasks/openclaw-development.yml @@ -83,27 +83,78 @@ msg: "Build failed - dist directory not found" when: not dist_dir.stat.exists -- name: Resolve openclaw CLI entrypoint path - ansible.builtin.shell: - cmd: | - set -euo pipefail - for rel in openclaw.mjs bin/openclaw.js dist/index.js; do - if [ -f "{{ openclaw_repo_dir }}/$rel" ]; then - printf '%s\n' "{{ openclaw_repo_dir }}/$rel" - exit 0 - fi - done - exit 1 - executable: /bin/bash - register: openclaw_cli_entry +- name: Check for package metadata + ansible.builtin.stat: + path: "{{ openclaw_repo_dir }}/package.json" + register: openclaw_package_json_stat + +- name: Read package metadata + ansible.builtin.slurp: + src: "{{ openclaw_repo_dir }}/package.json" + register: openclaw_package_json_raw + when: openclaw_package_json_stat.stat.exists + +- name: Parse package metadata + ansible.builtin.set_fact: + openclaw_package_json: "{{ openclaw_package_json_raw.content | b64decode | from_json }}" + when: openclaw_package_json_stat.stat.exists + +- name: Resolve metadata-defined CLI entrypoint + ansible.builtin.set_fact: + openclaw_package_bin_entry: >- + {{ + openclaw_package_json.bin + if openclaw_package_json.bin is string else + ( + openclaw_package_json.bin.openclaw + if openclaw_package_json.bin is mapping and 'openclaw' in openclaw_package_json.bin else + ( + (openclaw_package_json.bin | dict2items | map(attribute='value') | list | first) + if openclaw_package_json.bin is mapping else + '' + ) + ) + }} + when: openclaw_package_json_stat.stat.exists + +- name: Build CLI entrypoint candidate list + ansible.builtin.set_fact: + openclaw_cli_candidate_paths: >- + {{ + [ + openclaw_package_bin_entry | default(''), + 'openclaw.mjs', + 'bin/openclaw.js', + 'dist/index.js' + ] | reject('equalto', '') | unique | list + }} + +- name: Check possible OpenClaw CLI entrypoints + ansible.builtin.stat: + path: "{{ openclaw_repo_dir }}/{{ item }}" + loop: "{{ openclaw_cli_candidate_paths }}" + register: openclaw_cli_candidates + +- name: Resolve OpenClaw CLI entrypoint path + ansible.builtin.set_fact: + openclaw_cli_entry: >- + {{ + ( + openclaw_cli_candidates.results + | selectattr('stat.exists') + | map(attribute='stat.path') + | list + | first + ) | default('') + }} changed_when: false - name: Fail if openclaw CLI entrypoint is missing ansible.builtin.fail: msg: >- Unable to locate OpenClaw CLI entrypoint in {{ openclaw_repo_dir }}. - Expected one of: openclaw.mjs, bin/openclaw.js, dist/index.js - when: (openclaw_cli_entry.stdout | trim) == "" + Expected one of: {{ openclaw_cli_candidate_paths | join(', ') }} + when: openclaw_cli_entry == "" - name: Remove existing global openclaw symlink (if any) ansible.builtin.file: @@ -112,7 +163,7 @@ - name: Create symlink to openclaw binary ansible.builtin.file: - src: "{{ openclaw_cli_entry.stdout | trim }}" + src: "{{ openclaw_cli_entry }}" dest: "{{ openclaw_home }}/.local/bin/openclaw" state: link owner: "{{ openclaw_user }}" @@ -121,7 +172,7 @@ - name: Make openclaw binary executable ansible.builtin.file: - path: "{{ openclaw_cli_entry.stdout | trim }}" + path: "{{ openclaw_cli_entry }}" mode: '0755' owner: "{{ openclaw_user }}" group: "{{ openclaw_user }}" @@ -144,7 +195,7 @@ msg: | OpenClaw installed from source: {{ openclaw_dev_version.stdout }} Repository: {{ openclaw_repo_dir }} - Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_cli_entry.stdout | trim }} + Binary: {{ openclaw_home }}/.local/bin/openclaw -> {{ openclaw_cli_entry }} - name: Add development mode info to .bashrc ansible.builtin.blockinfile: