diff --git a/install.sh b/install.sh index 91d771b..5d8e373 100755 --- a/install.sh +++ b/install.sh @@ -195,16 +195,47 @@ install_vscode_extension() { return 1 fi - local root_flags="" + info "Installing Kilo Code extension ($VSCODE_EXTENSION)..." + + # 1. Install for current user (no custom --user-data-dir so it lands in standard location) + "$bin" --install-extension "$VSCODE_EXTENSION" --force || { + warn "Marketplace failed, trying OpenVSX..." + "$bin" --install-extension "https://open-vsx.org/extension/kilocode/kilo-code" --force || warn "Extension install failed for current user." + } + + # 2. If root, also install for every regular user with a home directory if [ "$EUID" -eq 0 ]; then - root_flags="--no-sandbox --user-data-dir=/tmp/vscode-root" + local ext_dir="/usr/share/code/resources/app/extensions" + [ -d "$ext_dir" ] || ext_dir="/usr/share/vscode/resources/app/extensions" + [ -d "$ext_dir" ] || ext_dir="" + + for user_home in /home/*; do + [ -d "$user_home" ] || continue + local user_name + user_name=$(basename "$user_home") + # Only real users with uid >= 1000 + local user_uid + user_uid=$(id -u "$user_name" 2>/dev/null || echo 0) + [ "$user_uid" -ge 1000 ] || continue + + info "Installing Kilo Code extension for user: $user_name ..." + su - "$user_name" -c "$bin --install-extension $VSCODE_EXTENSION --force" || { + warn "Marketplace failed for $user_name, trying OpenVSX..." + su - "$user_name" -c "$bin --install-extension https://open-vsx.org/extension/kilocode/kilo-code --force" || warn "Extension install failed for $user_name." + } + done + + # 3. Try system-wide install (copy into VS Code's bundled extensions) + if [ -n "$ext_dir" ] && [ -d "$ext_dir" ]; then + local current_user_ext + current_user_ext=$(ls -d "$HOME/.vscode/extensions/kilocode.kilo-code-"* 2>/dev/null | head -1) + if [ -n "$current_user_ext" ] && [ ! -d "$ext_dir/kilocode.kilo-code" ]; then + info "Copying extension to system-wide directory..." + cp -r "$current_user_ext" "$ext_dir/" && ok "System-wide extension installed" || warn "System-wide copy failed (permissions)." + fi + fi fi - info "Installing Kilo Code extension ($VSCODE_EXTENSION)..." - "$bin" $root_flags --install-extension "$VSCODE_EXTENSION" --force || { - warn "Extension install via marketplace failed, trying OpenVSX..." - "$bin" $root_flags --install-extension "https://open-vsx.org/extension/kilocode/kilo-code" --force || warn "Extension install failed. Install manually from Extensions panel." - } ok "Kilo Code extension installed" } @@ -241,16 +272,15 @@ print_summary() { echo "========================================" local vscode_ver="N/A" if command -v code &>/dev/null; then - if [ "$EUID" -eq 0 ]; then - vscode_ver=$(code --no-sandbox --user-data-dir=/tmp/vscode-root --version 2>/dev/null | head -1 || echo "VS Code (root)") - else - vscode_ver=$(code --version 2>/dev/null | head -1 || echo "VS Code") - fi + vscode_ver=$(code --version 2>/dev/null | head -1 || echo "VS Code") elif command -v codium &>/dev/null; then vscode_ver=$(codium --version 2>/dev/null | head -1 || echo "VSCodium") fi ok "VS Code: $vscode_ver" ok "Kilo Ext: $VSCODE_EXTENSION" + if [ "$EUID" -eq 0 ]; then + ok "Kilo Users: root + all regular users (/home/*)" + fi ok "Node: $(node --version 2>/dev/null || echo 'N/A')" ok "Bun: $(bun --version 2>/dev/null || echo 'N/A')" ok "Docker: $(docker --version 2>/dev/null || echo 'N/A')" @@ -261,6 +291,11 @@ print_summary() { echo " cd $INSTALL_DIR" echo " code ." echo "" + if [ "$EUID" -eq 0 ]; then + echo " For root GUI sessions, if sandbox errors:" + echo " code --no-sandbox ." + echo "" + fi if [ "$dist" != "unknown" ] && ! id -nG "$USER" | grep -qw docker; then warn "Docker group change requires re-login. Run: newgrp docker" fi