Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(cli): install the CLI bundle via staged renames to survive busy binaries
jkomyno03c326a19a71
diff --git a/install.sh b/install.shindex a6ea15cab..57a56dc2c 100755--- a/install.sh+++ b/install.sh@@ -249,11 +249,33 @@ install_bundle() {warn 'This release archive has no bundled support files. Some CLI features may be unavailable.'fi- cp -Rp "$install_bundle_dir"/. "$resolved_install_dir/" ||- error "Failed to install the CLI bundle to \"$resolved_install_dir\""- chmod +x "$resolved_install_dir/composio" || error 'Failed to set permissions on executable'- printf '%s\n' "$version" >"$resolved_install_dir/release-tag.txt" ||- error "Failed to write install metadata to \"$resolved_install_dir/release-tag.txt\""+ # Stage the bundle on the same filesystem as the install dir, then move each+ # top-level entry into place. rename() replaces a running binary atomically,+ # where copying through the old inode fails with ETXTBSY on Linux and would+ # leave a mixed old-binary/new-support-files install behind.+ install_staging_dir=$resolved_install_dir/.composio-install-staging.$$+ rm -rf "$install_staging_dir"+ mkdir -p "$install_staging_dir" ||+ error "Failed to create staging directory \"$install_staging_dir\""+ cp -Rp "$install_bundle_dir"/. "$install_staging_dir/" ||+ error "Failed to stage the CLI bundle in \"$install_staging_dir\""+ chmod +x "$install_staging_dir/composio" || error 'Failed to set permissions on executable'+ printf '%s\n' "$version" >"$install_staging_dir/release-tag.txt" ||+ error "Failed to write install metadata to \"$install_staging_dir/release-tag.txt\""++ for install_entry in "$install_staging_dir"/* "$install_staging_dir"/.[!.]* "$install_staging_dir"/..?*; do+ [ -e "$install_entry" ] || [ -L "$install_entry" ] || continue+ install_entry_name=${install_entry##*/}+ install_entry_target=$resolved_install_dir/$install_entry_name+ # Directories cannot be replaced by rename(); drop the outgoing entry so+ # bundle directories are replaced wholesale rather than merged.+ if [ -d "$install_entry" ] || [ -d "$install_entry_target" ]; then+ rm -rf "$install_entry_target"+ fi+ mv -f "$install_entry" "$install_entry_target" ||+ error "Failed to install the CLI bundle to \"$resolved_install_dir\""+ done+ rm -rf "$install_staging_dir"}install_entry_point() {@@ -398,6 +420,9 @@ cleanup() {if [ -n "${tmpdir:-}" ] && [ -d "$tmpdir" ]; thenrm -rf "$tmpdir"fi+ if [ -n "${install_staging_dir:-}" ] && [ -d "$install_staging_dir" ]; then+ rm -rf "$install_staging_dir"+ fi}cleanup_on_signal() {diff --git a/test/install-sh-release-resolution.test.sh b/test/install-sh-release-resolution.test.shindex 078c76f18..1566faf5f 100755--- a/test/install-sh-release-resolution.test.sh+++ b/test/install-sh-release-resolution.test.sh@@ -385,6 +385,20 @@ EOF[[ -x "$equal_dir/composio" && ! -L "$equal_dir/composio" ]] || fail "$interpreter_name equal-dir layout"[[ $(<"$equal_dir/release-tag.txt") == "$beta_tag" ]] || fail "$interpreter_name explicit beta tag"+ reset_case+ upgrade_home="$case_root/upgrade-home"+ upgrade_install="$case_root/upgrade-install"+ upgrade_bin="$case_root/upgrade-bin"+ mkdir -p "$upgrade_install/services"+ printf '%s\n' stale >"$upgrade_install/services/stale.txt"+ printf '%s\n' old-binary >"$upgrade_install/composio"+ run_installer "$upgrade_home" "$upgrade_install" "$upgrade_bin" "$stable_tag" >/dev/null 2>&1+ [[ -x "$upgrade_install/composio" ]] || fail "$interpreter_name upgrade must replace the existing binary"+ [[ $(<"$upgrade_install/services/example.txt") == service ]] || fail "$interpreter_name upgrade must install new support files"+ [[ ! -e "$upgrade_install/services/stale.txt" ]] || fail "$interpreter_name upgrade must replace bundle directories wholesale"+ [[ -z $(find "$upgrade_install" -maxdepth 1 -name '.composio-install-staging.*' -print -quit) ]] ||+ fail "$interpreter_name upgrade must clean up the staging directory"+reset_caselegacy_home="$case_root/legacy-home"mkdir -p "$legacy_home"