@devries-cameron20 / composio Mirror · read-only / commits / 03c326a19
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 17:15 UTC

fix(cli): install the CLI bundle via staged renames to survive busy binaries

jkomyno committed Aug 3, 2026 at 20:26 UTC 03c326a19a7189a147cb536a677d4e16e6b0aa38
2 files changed +44 -5
install.sh
+30 -5
@@ -249,11 +249,33 @@ install_bundle() {
249 warn 'This release archive has no bundled support files. Some CLI features may be unavailable.'
250 fi
251
252 - cp -Rp "$install_bundle_dir"/. "$resolved_install_dir/" ||
253 - error "Failed to install the CLI bundle to \"$resolved_install_dir\""
254 - chmod +x "$resolved_install_dir/composio" || error 'Failed to set permissions on executable'
255 - printf '%s\n' "$version" >"$resolved_install_dir/release-tag.txt" ||
256 - error "Failed to write install metadata to \"$resolved_install_dir/release-tag.txt\""
252 + # Stage the bundle on the same filesystem as the install dir, then move each
253 + # top-level entry into place. rename() replaces a running binary atomically,
254 + # where copying through the old inode fails with ETXTBSY on Linux and would
255 + # leave a mixed old-binary/new-support-files install behind.
256 + install_staging_dir=$resolved_install_dir/.composio-install-staging.$$
257 + rm -rf "$install_staging_dir"
258 + mkdir -p "$install_staging_dir" ||
259 + error "Failed to create staging directory \"$install_staging_dir\""
260 + cp -Rp "$install_bundle_dir"/. "$install_staging_dir/" ||
261 + error "Failed to stage the CLI bundle in \"$install_staging_dir\""
262 + chmod +x "$install_staging_dir/composio" || error 'Failed to set permissions on executable'
263 + printf '%s\n' "$version" >"$install_staging_dir/release-tag.txt" ||
264 + error "Failed to write install metadata to \"$install_staging_dir/release-tag.txt\""
265 +
266 + for install_entry in "$install_staging_dir"/* "$install_staging_dir"/.[!.]* "$install_staging_dir"/..?*; do
267 + [ -e "$install_entry" ] || [ -L "$install_entry" ] || continue
268 + install_entry_name=${install_entry##*/}
269 + install_entry_target=$resolved_install_dir/$install_entry_name
270 + # Directories cannot be replaced by rename(); drop the outgoing entry so
271 + # bundle directories are replaced wholesale rather than merged.
272 + if [ -d "$install_entry" ] || [ -d "$install_entry_target" ]; then
273 + rm -rf "$install_entry_target"
274 + fi
275 + mv -f "$install_entry" "$install_entry_target" ||
276 + error "Failed to install the CLI bundle to \"$resolved_install_dir\""
277 + done
278 + rm -rf "$install_staging_dir"
279 }
280
281 install_entry_point() {
@@ -398,6 +420,9 @@ cleanup() {
420 if [ -n "${tmpdir:-}" ] && [ -d "$tmpdir" ]; then
421 rm -rf "$tmpdir"
422 fi
423 + if [ -n "${install_staging_dir:-}" ] && [ -d "$install_staging_dir" ]; then
424 + rm -rf "$install_staging_dir"
425 + fi
426 }
427
428 cleanup_on_signal() {
test/install-sh-release-resolution.test.sh
+14
@@ -385,6 +385,20 @@ EOF
385 [[ -x "$equal_dir/composio" && ! -L "$equal_dir/composio" ]] || fail "$interpreter_name equal-dir layout"
386 [[ $(<"$equal_dir/release-tag.txt") == "$beta_tag" ]] || fail "$interpreter_name explicit beta tag"
387
388 + reset_case
389 + upgrade_home="$case_root/upgrade-home"
390 + upgrade_install="$case_root/upgrade-install"
391 + upgrade_bin="$case_root/upgrade-bin"
392 + mkdir -p "$upgrade_install/services"
393 + printf '%s\n' stale >"$upgrade_install/services/stale.txt"
394 + printf '%s\n' old-binary >"$upgrade_install/composio"
395 + run_installer "$upgrade_home" "$upgrade_install" "$upgrade_bin" "$stable_tag" >/dev/null 2>&1
396 + [[ -x "$upgrade_install/composio" ]] || fail "$interpreter_name upgrade must replace the existing binary"
397 + [[ $(<"$upgrade_install/services/example.txt") == service ]] || fail "$interpreter_name upgrade must install new support files"
398 + [[ ! -e "$upgrade_install/services/stale.txt" ]] || fail "$interpreter_name upgrade must replace bundle directories wholesale"
399 + [[ -z $(find "$upgrade_install" -maxdepth 1 -name '.composio-install-staging.*' -print -quit) ]] ||
400 + fail "$interpreter_name upgrade must clean up the staging directory"
401 +
402 reset_case
403 legacy_home="$case_root/legacy-home"
404 mkdir -p "$legacy_home"