Skip to content

Conversation

@kkashilk
Copy link
Contributor

Issue #, if available:
Add Q CLI installation script

Description of changes:
Add installation script for Q CLI that:

  • Detects platform (macOS/Linux) and architecture
  • Downloads appropriate package from release CDN
  • Verifies checksums and GPG signatures
  • Handles both glibc and musl Linux variants
  • Provides interactive installation with progress feedback
  • Includes cleanup of temporary files

🤖 Assisted by Amazon Q Developer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kkashilk kkashilk requested a review from a team as a code owner October 21, 2025 22:11

local glibc_version
if command -v ldd >/dev/null 2>&1; then
glibc_version=$(ldd --version 2>/dev/null | head -1 | grep -o '[0-9]\+\.[0-9]\+' | head -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know how reliable this check is? Can this be a common function that has multiple checks? https://github.com/aws/amazon-q-developer-cli-autocomplete/blob/main/bundle/linux/install.sh#L83

Also consider defining constants for the supported versions

readonly MIN_GLIBC_MAJOR=2
readonly MIN_GLIBC_MINOR=34

@@ -0,0 +1,522 @@
#!/bin/bash

set -e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding set -eu as well to avoid silent errors (also set -o pipefail potentially although probably not needed)

local app_name
app_name=$(basename "$app_bundle")

log "Installing $app_name to $MACOS_APP_DIR..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the desktop app is already running? Won't this break in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this, and didn't see a failure. I think this scenario is unlikely too, IOW most users wouldn't run the install script if they have q-cli/kiro installed already and were running the Desktop app already


mkdir -p "$HOME/.local/bin"
local macos_bin="$MACOS_APP_DIR/$app_name/Contents/MacOS"
cp -f "$macos_bin/q" "$macos_bin/qchat" "$macos_bin/qterm" "$HOME/.local/bin/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be symlinks like they are currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

fi

cp -R "$app_bundle" "$MACOS_APP_DIR/"

Copy link

@akhileshb akhileshb Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to download the binary from console and open the application, Mac gives a warning

"“Amazon Q” is an app downloaded from the Internet. Are you sure you want to open it?"

Searching in the internet, found that this can flag can be removed. Should we add something like this since we are installing this via CLI and would want to automate this action

xattr -dr com.apple.quarantine "$MACOS_APP_DIR/$app_name" 2>/dev/null || true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, will this quarantine flag be set when downloading the DMG in the terminal 🤔

https://stackoverflow.com/questions/46198557/understanding-output-of-xattr-p-com-apple-quarantine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it would not be set, thats my point.

As of today, once the desktop is installed, developers have to open the App atleast one time to setup things up (thats my understanding, correct me if I am wrong and its its not a prerequisite) for thing to be setup during which UX would appear to trust the App which would be set this flag

However, in this new world that user flow is gone and user is NOT going to open the App to get going. Hence setting this flag would enable us to automatically open it (by us behind the scenes if needed) or in future when user opens it they don't have o go through that trust UX flow.


hdiutil detach "$mount_path" -quiet

mkdir -p "$HOME/.local/bin"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ~/.local/bin and not /usr/local/bin.

By default, user local is included in the path but don't think .local bin is. I currently see my Q is in local bin, so guessing this is precedence and the desktop App does this symlink today?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, we've always created symlink in the ~/home/.local/bin folder.
See -

let dest = local_bin.join(CLI_BINARY_NAME);

Comment on lines 456 to 478
echo
success "$CLI_NAME installation completed successfully!"
echo
echo "Next steps:"
echo "1. Run: $COMMAND_NAME --help to get started"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end sticking with ~/.local/bin for the application location. We should check if it exists in the path and if not warn users to add that in your shell profile. If not this command would not work for them.

Also, we should show where we installed the binary so that its clear where the finally executable is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to print it out, or is it enough to document it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its in the path, we could omit it. But when its not in the path, we need to print it and suggest to add that to their path

}

# Cleanup function - only removes files/dirs we created
cleanup() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a happy case, we show "install complete". However due to whatever issue, we fail we need to communicate that as well

This might be a good place to show that since this cleanup would be called after the script ends "Installation failed. Cleaning up"

SUCCESS=false

cleanup() {
    if [ "$SUCCESS" = false ]; then
        echo "Installation failed. Cleaning up"
    fi
     // clean code
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

fi

local mount_path
mount_path=$(hdiutil attach "$dmg_path" -nobrowse | grep Volumes | cut -f 3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just do -readonly just to be safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure


cp -R "$app_bundle" "$MACOS_APP_DIR/"

hdiutil detach "$mount_path" -quiet

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this in the cleanup as independent of any success/fails we want to unmount it?

For example, say the above copy files, we want to un mount. I know you already add this in few if conditions above, rather it might make sense to handle this in catch all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, makes sense to detach in the finally block

Add comprehensive installation script for Q CLI that:
- Detects platform (macOS/Linux) and architecture
- Downloads appropriate package from release CDN
- Verifies checksums and GPG signatures
- Handles both glibc and musl Linux variants
- Provides interactive installation with progress feedback
- Includes cleanup of temporary files

🤖 Assisted by Amazon Q Developer
- Check if ~/.local/bin is on PATH after installation and warn users
- Skip setup commands when Linux install.sh is called from main installer
- Add Q_SKIP_SETUP environment variable to control setup execution
@kkashilk kkashilk merged commit 340c07c into main Oct 24, 2025
19 of 27 checks passed
@kkashilk kkashilk deleted the install-script branch October 24, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants