fix(ui-desktop): unify path resolution around GOOSE_PATH_ROOT (#7335)
Signed-off-by: Vadim Polulyakh <bavadim@gmail.com> Co-authored-by: Jack Amadeo <jackamadeo@block.xyz>
This commit is contained in:
@@ -23,32 +23,43 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
|
||||
|
||||
log "Starting node setup (common)."
|
||||
|
||||
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
|
||||
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
|
||||
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
|
||||
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
|
||||
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
|
||||
else
|
||||
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
|
||||
fi
|
||||
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
|
||||
|
||||
# One-time cleanup for existing Linux users to fix locking issues
|
||||
CLEANUP_MARKER="${HOME}/.config/goose/.mcp-hermit-cleanup-v1"
|
||||
CLEANUP_MARKER="${RESOLVED_GOOSE_CONFIG_DIR}/.mcp-hermit-cleanup-v1"
|
||||
if [[ "$(uname -s)" == "Linux" ]] && [ ! -f "${CLEANUP_MARKER}" ]; then
|
||||
log "Performing one-time cleanup of old mcp-hermit directory to fix locking issues."
|
||||
if [ -d "${HOME}/.config/goose/mcp-hermit" ]; then
|
||||
rm -rf "${HOME}/.config/goose/mcp-hermit"
|
||||
if [ -d "${MCP_HERMIT_DIR}" ]; then
|
||||
rm -rf "${MCP_HERMIT_DIR}"
|
||||
log "Removed old mcp-hermit directory."
|
||||
fi
|
||||
mkdir -p "${RESOLVED_GOOSE_CONFIG_DIR}"
|
||||
touch "${CLEANUP_MARKER}"
|
||||
log "Cleanup completed. Marker file created."
|
||||
fi
|
||||
|
||||
# Ensure ${HOME}/.config/goose/mcp-hermit/bin exists
|
||||
log "Creating directory ${HOME}/.config/goose/mcp-hermit/bin if it does not exist."
|
||||
mkdir -p "${HOME}/.config/goose/mcp-hermit/bin"
|
||||
# Ensure mcp-hermit/bin exists
|
||||
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
|
||||
mkdir -p "${MCP_HERMIT_DIR}/bin"
|
||||
|
||||
# Change to the ${HOME}/.config/goose/mcp-hermit directory
|
||||
log "Changing to directory ${HOME}/.config/goose/mcp-hermit."
|
||||
cd "${HOME}/.config/goose/mcp-hermit"
|
||||
# Change to the mcp-hermit directory
|
||||
log "Changing to directory ${MCP_HERMIT_DIR}."
|
||||
cd "${MCP_HERMIT_DIR}"
|
||||
|
||||
|
||||
# Check if hermit binary exists and download if not
|
||||
if [ ! -f "${HOME}/.config/goose/mcp-hermit/bin/hermit" ]; then
|
||||
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
|
||||
log "Hermit binary not found. Downloading hermit binary."
|
||||
curl -fsSL "https://github.com/cashapp/hermit/releases/download/stable/hermit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').gz" \
|
||||
| gzip -dc > "${HOME}/.config/goose/mcp-hermit/bin/hermit" && chmod +x "${HOME}/.config/goose/mcp-hermit/bin/hermit"
|
||||
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
|
||||
log "Hermit binary downloaded and made executable."
|
||||
else
|
||||
log "Hermit binary already exists. Skipping download."
|
||||
@@ -56,13 +67,13 @@ fi
|
||||
|
||||
|
||||
log "setting hermit cache to be local for MCP servers"
|
||||
mkdir -p "${HOME}/.config/goose/mcp-hermit/cache"
|
||||
export HERMIT_STATE_DIR="${HOME}/.config/goose/mcp-hermit/cache"
|
||||
mkdir -p "${MCP_HERMIT_DIR}/cache"
|
||||
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
|
||||
|
||||
|
||||
# Update PATH
|
||||
export PATH="${HOME}/.config/goose/mcp-hermit/bin:${PATH}"
|
||||
log "Updated PATH to include ${HOME}/.config/goose/mcp-hermit/bin."
|
||||
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
|
||||
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
|
||||
|
||||
|
||||
# Verify hermit installation
|
||||
@@ -78,7 +89,7 @@ if [ ! -f "bin/activate-hermit" ]; then
|
||||
log "Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks."
|
||||
HERMIT_TMP_DIR="/tmp/hermit_tmp_$$/bin"
|
||||
mkdir -p "${HERMIT_TMP_DIR}"
|
||||
cp "${HOME}/.config/goose/mcp-hermit/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
|
||||
cp "${MCP_HERMIT_DIR}/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
|
||||
chmod +x "${HERMIT_TMP_DIR}/hermit"
|
||||
export PATH="${HERMIT_TMP_DIR}:${PATH}"
|
||||
HERMIT_CLEANUP_DIR="/tmp/hermit_tmp_$$"
|
||||
@@ -124,10 +135,10 @@ if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "${GOOSE_NPM_REGIST
|
||||
# Check if GOOSE_NPM_CERT is set and accessible
|
||||
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "${GOOSE_NPM_CERT}" > /dev/null; then
|
||||
log "Downloading certificate from: ${GOOSE_NPM_CERT}"
|
||||
curl -sSL -o "${HOME}/.config/goose/mcp-hermit/cert.pem" "${GOOSE_NPM_CERT}"
|
||||
curl -sSL -o "${MCP_HERMIT_DIR}/cert.pem" "${GOOSE_NPM_CERT}"
|
||||
if [ $? -eq 0 ]; then
|
||||
log "Certificate downloaded successfully."
|
||||
export NODE_EXTRA_CA_CERTS="${HOME}/.config/goose/mcp-hermit/cert.pem"
|
||||
export NODE_EXTRA_CA_CERTS="${MCP_HERMIT_DIR}/cert.pem"
|
||||
else
|
||||
log "Unable to download the certificate. Skipping certificate setup."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user