Skip to content

Commit a0d7d99

Browse files
authored
Feat/install dir hint and volume conflict check (#15)
1 parent c6098b2 commit a0d7d99

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

install/hiclaw-install.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ function Install-Manager {
636636

637637
Write-Log "Registry: $($script:HICLAW_REGISTRY)"
638638
Write-Log ""
639+
Write-Log "Installation directory: $(Get-Location)"
640+
Write-Log " (The env file 'hiclaw-manager.env' will be created in this directory.)"
641+
Write-Log " (Run this script from the directory where you want to manage this installation.)"
642+
Write-Log ""
639643

640644
# Check Docker
641645
if (-not (Test-DockerRunning)) {
@@ -1078,6 +1082,31 @@ function Install-Manager {
10781082
docker rm hiclaw-manager *>$null
10791083
}
10801084

1085+
# Check if the Docker volume is already owned by a different installation directory
1086+
$volumeExists = docker volume ls -q 2>$null | Select-String "^$($config.DATA_DIR)$"
1087+
if ($volumeExists) {
1088+
$existingInstallPath = (docker volume inspect $config.DATA_DIR --format '{{index .Labels "hiclaw.install-path"}}' 2>$null) -join ""
1089+
$currentInstallPath = (Get-Location).Path
1090+
if ($existingInstallPath -and $existingInstallPath.Trim() -ne $currentInstallPath) {
1091+
Write-Host ""
1092+
Write-Host "`e[31m[HiClaw ERROR] Volume conflict detected!`e[0m"
1093+
Write-Host "`e[31m Docker volume '$($config.DATA_DIR)' was created by a different installation:`e[0m"
1094+
Write-Host "`e[31m Original install directory : $($existingInstallPath.Trim())`e[0m"
1095+
Write-Host "`e[31m Current install directory : $currentInstallPath`e[0m"
1096+
Write-Host ""
1097+
Write-Host "`e[33m Each HiClaw installation must use its own Docker volume.`e[0m"
1098+
Write-Host "`e[33m Options:`e[0m"
1099+
Write-Host "`e[33m 1. Run this script from the original directory: $($existingInstallPath.Trim())`e[0m"
1100+
Write-Host "`e[33m 2. Use a different volume name: `$env:HICLAW_DATA_DIR='hiclaw-data-2'; .\hiclaw-install.ps1`e[0m"
1101+
Write-Host "`e[33m 3. Perform a clean reinstall from the original directory (option 2 in the upgrade menu)`e[0m"
1102+
Write-Host ""
1103+
throw "Volume conflict: cannot reuse volume '$($config.DATA_DIR)' from a different installation directory."
1104+
}
1105+
} else {
1106+
# Create the volume with an install-path label so future installs can detect conflicts
1107+
docker volume create --label "hiclaw.install-path=$($(Get-Location).Path)" $config.DATA_DIR | Out-Null
1108+
}
1109+
10811110
# Pull images (skip if already exists locally)
10821111
# For local images (prefix "hiclaw/"), skip pull if exists
10831112
# For remote images, always pull to get updates

install/hiclaw-install.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ install_manager() {
485485
log "=== HiClaw Manager Installation ==="
486486
log "Registry: ${HICLAW_REGISTRY}"
487487
log ""
488+
log "Installation directory: $(pwd)"
489+
log " (The env file 'hiclaw-manager.env' will be created in this directory.)"
490+
log " (Run this script from the directory where you want to manage this installation.)"
491+
log ""
488492

489493
# Onboarding mode selection (skip if already in non-interactive mode)
490494
if [ "${HICLAW_NON_INTERACTIVE}" != "1" ]; then
@@ -915,6 +919,31 @@ EOF
915919
docker rm hiclaw-manager 2>/dev/null || true
916920
fi
917921

922+
# Check if the Docker volume is already owned by a different installation directory
923+
if docker volume ls -q | grep -q "^${HICLAW_DATA_DIR}$"; then
924+
EXISTING_INSTALL_PATH=$(docker volume inspect "${HICLAW_DATA_DIR}" \
925+
--format '{{index .Labels "hiclaw.install-path"}}' 2>/dev/null || true)
926+
CURRENT_INSTALL_PATH="$(pwd)"
927+
if [ -n "${EXISTING_INSTALL_PATH}" ] && [ "${EXISTING_INSTALL_PATH}" != "${CURRENT_INSTALL_PATH}" ]; then
928+
echo ""
929+
echo -e "\033[31m[HiClaw ERROR] Volume conflict detected!\033[0m" >&2
930+
echo -e "\033[31m Docker volume '${HICLAW_DATA_DIR}' was created by a different installation:\033[0m" >&2
931+
echo -e "\033[31m Original install directory : ${EXISTING_INSTALL_PATH}\033[0m" >&2
932+
echo -e "\033[31m Current install directory : ${CURRENT_INSTALL_PATH}\033[0m" >&2
933+
echo "" >&2
934+
echo -e "\033[33m Each HiClaw installation must use its own Docker volume.\033[0m" >&2
935+
echo -e "\033[33m Options:\033[0m" >&2
936+
echo -e "\033[33m 1. Run this script from the original directory: ${EXISTING_INSTALL_PATH}\033[0m" >&2
937+
echo -e "\033[33m 2. Use a different volume name: HICLAW_DATA_DIR=hiclaw-data-2 $0\033[0m" >&2
938+
echo -e "\033[33m 3. Perform a clean reinstall from the original directory (option 2 in the upgrade menu)\033[0m" >&2
939+
echo "" >&2
940+
exit 1
941+
fi
942+
else
943+
# Create the volume with an install-path label so future installs can detect conflicts
944+
docker volume create --label "hiclaw.install-path=$(pwd)" "${HICLAW_DATA_DIR}" > /dev/null
945+
fi
946+
918947
# Data mount: Docker volume
919948
DATA_MOUNT_ARGS="-v ${HICLAW_DATA_DIR}:/data"
920949

openclaw-base/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ RUN git clone --depth 1 --single-branch \
5959
pnpm config set registry ${NPM_REGISTRY} && \
6060
pnpm install && \
6161
pnpm build && \
62+
echo "==> Verifying critical native addons..." && \
63+
ADDON_DIR=/opt/openclaw/node_modules/.pnpm/@matrix-org+matrix-sdk-crypto-nodejs@0.4.0/node_modules/@matrix-org/matrix-sdk-crypto-nodejs && \
64+
ls "$ADDON_DIR"/matrix-sdk-crypto.linux-*.node 2>/dev/null | grep -q . \
65+
|| (echo "ERROR: matrix-sdk-crypto native addon missing (pnpm install may have silently failed on this arch)" && exit 1) && \
66+
echo "==> Native addon check passed: $(ls $ADDON_DIR/matrix-sdk-crypto.linux-*.node)" && \
6267
rm -rf \
6368
.git .github \
6469
test \

0 commit comments

Comments
 (0)