Skip to content

Commit 12eac72

Browse files
bavadimjamadeo
andauthored
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>
1 parent f740bb7 commit 12eac72

File tree

5 files changed

+96
-46
lines changed

5 files changed

+96
-46
lines changed

ui/desktop/src/bin/jbang

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,41 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting jbang setup script."
2222

23-
# Ensure ~/.config/goose/mcp-hermit/bin exists
24-
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
25-
mkdir -p ~/.config/goose/mcp-hermit/bin
23+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
24+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
25+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
26+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
28+
else
29+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
30+
fi
31+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
32+
33+
# Ensure mcp-hermit/bin exists
34+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
35+
mkdir -p "${MCP_HERMIT_DIR}/bin"
2636

27-
# Change to the ~/.config/goose/mcp-hermit directory
28-
log "Changing to directory ~/.config/goose/mcp-hermit."
29-
cd ~/.config/goose/mcp-hermit
37+
# Change to the mcp-hermit directory
38+
log "Changing to directory ${MCP_HERMIT_DIR}."
39+
cd "${MCP_HERMIT_DIR}"
3040

3141
# Check if hermit binary exists and download if not
32-
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
42+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
3343
log "Hermit binary not found. Downloading hermit binary."
3444
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" \
35-
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
45+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
3646
log "Hermit binary downloaded and made executable."
3747
else
3848
log "Hermit binary already exists. Skipping download."
3949
fi
4050

4151
log "setting hermit cache to be local for MCP servers"
42-
mkdir -p ~/.config/goose/mcp-hermit/cache
43-
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
52+
mkdir -p "${MCP_HERMIT_DIR}/cache"
53+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
4454

4555
# Update PATH
46-
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
47-
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
56+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
57+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
4858

4959
# Initialize hermit
5060
log "Initializing hermit."
@@ -55,10 +65,10 @@ log "Installing OpenJDK with hermit."
5565
hermit install openjdk@17 >> "$LOG_FILE"
5666

5767
# Download and install jbang if not present
58-
if [ ! -f ~/.config/goose/mcp-hermit/bin/jbang ]; then
68+
if [ ! -f "${MCP_HERMIT_DIR}/bin/jbang" ]; then
5969
log "Downloading and installing jbang."
6070
curl -Ls https://sh.jbang.dev | bash -s - app setup
61-
cp ~/.jbang/bin/jbang ~/.config/goose/mcp-hermit/bin/
71+
cp ~/.jbang/bin/jbang "${MCP_HERMIT_DIR}/bin/"
6272
fi
6373

6474
# Verify installations
@@ -86,4 +96,4 @@ jbang --quiet trust add *
8696
log "Executing 'jbang' command with arguments: $*"
8797
jbang --fresh --quiet "$@" || log "Failed to execute 'jbang' with arguments: $*"
8898

89-
log "jbang setup script completed successfully."
99+
log "jbang setup script completed successfully."

ui/desktop/src/bin/node-setup-common.sh

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,57 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2323

2424
log "Starting node setup (common)."
2525

26+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
28+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
29+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
30+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
31+
else
32+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
33+
fi
34+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
35+
2636
# One-time cleanup for existing Linux users to fix locking issues
27-
CLEANUP_MARKER="${HOME}/.config/goose/.mcp-hermit-cleanup-v1"
37+
CLEANUP_MARKER="${RESOLVED_GOOSE_CONFIG_DIR}/.mcp-hermit-cleanup-v1"
2838
if [[ "$(uname -s)" == "Linux" ]] && [ ! -f "${CLEANUP_MARKER}" ]; then
2939
log "Performing one-time cleanup of old mcp-hermit directory to fix locking issues."
30-
if [ -d "${HOME}/.config/goose/mcp-hermit" ]; then
31-
rm -rf "${HOME}/.config/goose/mcp-hermit"
40+
if [ -d "${MCP_HERMIT_DIR}" ]; then
41+
rm -rf "${MCP_HERMIT_DIR}"
3242
log "Removed old mcp-hermit directory."
3343
fi
44+
mkdir -p "${RESOLVED_GOOSE_CONFIG_DIR}"
3445
touch "${CLEANUP_MARKER}"
3546
log "Cleanup completed. Marker file created."
3647
fi
3748

38-
# Ensure ${HOME}/.config/goose/mcp-hermit/bin exists
39-
log "Creating directory ${HOME}/.config/goose/mcp-hermit/bin if it does not exist."
40-
mkdir -p "${HOME}/.config/goose/mcp-hermit/bin"
49+
# Ensure mcp-hermit/bin exists
50+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
51+
mkdir -p "${MCP_HERMIT_DIR}/bin"
4152

42-
# Change to the ${HOME}/.config/goose/mcp-hermit directory
43-
log "Changing to directory ${HOME}/.config/goose/mcp-hermit."
44-
cd "${HOME}/.config/goose/mcp-hermit"
53+
# Change to the mcp-hermit directory
54+
log "Changing to directory ${MCP_HERMIT_DIR}."
55+
cd "${MCP_HERMIT_DIR}"
4556

4657

4758
# Check if hermit binary exists and download if not
48-
if [ ! -f "${HOME}/.config/goose/mcp-hermit/bin/hermit" ]; then
59+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
4960
log "Hermit binary not found. Downloading hermit binary."
5061
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" \
51-
| gzip -dc > "${HOME}/.config/goose/mcp-hermit/bin/hermit" && chmod +x "${HOME}/.config/goose/mcp-hermit/bin/hermit"
62+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
5263
log "Hermit binary downloaded and made executable."
5364
else
5465
log "Hermit binary already exists. Skipping download."
5566
fi
5667

5768

5869
log "setting hermit cache to be local for MCP servers"
59-
mkdir -p "${HOME}/.config/goose/mcp-hermit/cache"
60-
export HERMIT_STATE_DIR="${HOME}/.config/goose/mcp-hermit/cache"
70+
mkdir -p "${MCP_HERMIT_DIR}/cache"
71+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
6172

6273

6374
# Update PATH
64-
export PATH="${HOME}/.config/goose/mcp-hermit/bin:${PATH}"
65-
log "Updated PATH to include ${HOME}/.config/goose/mcp-hermit/bin."
75+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
76+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
6677

6778

6879
# Verify hermit installation
@@ -78,7 +89,7 @@ if [ ! -f "bin/activate-hermit" ]; then
7889
log "Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks."
7990
HERMIT_TMP_DIR="/tmp/hermit_tmp_$$/bin"
8091
mkdir -p "${HERMIT_TMP_DIR}"
81-
cp "${HOME}/.config/goose/mcp-hermit/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
92+
cp "${MCP_HERMIT_DIR}/bin/hermit" "${HERMIT_TMP_DIR}/hermit"
8293
chmod +x "${HERMIT_TMP_DIR}/hermit"
8394
export PATH="${HERMIT_TMP_DIR}:${PATH}"
8495
HERMIT_CLEANUP_DIR="/tmp/hermit_tmp_$$"
@@ -124,10 +135,10 @@ if [ -n "${GOOSE_NPM_REGISTRY:-}" ] && curl -s --head --fail "${GOOSE_NPM_REGIST
124135
# Check if GOOSE_NPM_CERT is set and accessible
125136
if [ -n "${GOOSE_NPM_CERT:-}" ] && curl -s --head --fail "${GOOSE_NPM_CERT}" > /dev/null; then
126137
log "Downloading certificate from: ${GOOSE_NPM_CERT}"
127-
curl -sSL -o "${HOME}/.config/goose/mcp-hermit/cert.pem" "${GOOSE_NPM_CERT}"
138+
curl -sSL -o "${MCP_HERMIT_DIR}/cert.pem" "${GOOSE_NPM_CERT}"
128139
if [ $? -eq 0 ]; then
129140
log "Certificate downloaded successfully."
130-
export NODE_EXTRA_CA_CERTS="${HOME}/.config/goose/mcp-hermit/cert.pem"
141+
export NODE_EXTRA_CA_CERTS="${MCP_HERMIT_DIR}/cert.pem"
131142
else
132143
log "Unable to download the certificate. Skipping certificate setup."
133144
fi

ui/desktop/src/bin/uvx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,42 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting uvx setup script."
2222

23-
# Ensure ~/.config/goose/mcp-hermit/bin exists
24-
log "Creating directory ~/.config/goose/mcp-hermit/bin if it does not exist."
25-
mkdir -p ~/.config/goose/mcp-hermit/bin
23+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
24+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
25+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
26+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
28+
else
29+
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
30+
fi
31+
MCP_HERMIT_DIR="${RESOLVED_GOOSE_CONFIG_DIR}/mcp-hermit"
32+
33+
# Ensure mcp-hermit/bin exists
34+
log "Creating directory ${MCP_HERMIT_DIR}/bin if it does not exist."
35+
mkdir -p "${MCP_HERMIT_DIR}/bin"
2636

27-
# Change to the ~/.config/goose/mcp-hermit directory
28-
log "Changing to directory ~/.config/goose/mcp-hermit."
29-
cd ~/.config/goose/mcp-hermit
37+
# Change to the mcp-hermit directory
38+
log "Changing to directory ${MCP_HERMIT_DIR}."
39+
cd "${MCP_HERMIT_DIR}"
3040

3141
# Check if hermit binary exists and download if not
32-
if [ ! -f ~/.config/goose/mcp-hermit/bin/hermit ]; then
42+
if [ ! -f "${MCP_HERMIT_DIR}/bin/hermit" ]; then
3343
log "Hermit binary not found. Downloading hermit binary."
3444
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" \
35-
| gzip -dc > ~/.config/goose/mcp-hermit/bin/hermit && chmod +x ~/.config/goose/mcp-hermit/bin/hermit
45+
| gzip -dc > "${MCP_HERMIT_DIR}/bin/hermit" && chmod +x "${MCP_HERMIT_DIR}/bin/hermit"
3646
log "Hermit binary downloaded and made executable."
3747
else
3848
log "Hermit binary already exists. Skipping download."
3949
fi
4050

4151

4252
log "setting hermit cache to be local for MCP servers"
43-
mkdir -p ~/.config/goose/mcp-hermit/cache
44-
export HERMIT_STATE_DIR=~/.config/goose/mcp-hermit/cache
53+
mkdir -p "${MCP_HERMIT_DIR}/cache"
54+
export HERMIT_STATE_DIR="${MCP_HERMIT_DIR}/cache"
4555

4656
# Update PATH
47-
export PATH=~/.config/goose/mcp-hermit/bin:$PATH
48-
log "Updated PATH to include ~/.config/goose/mcp-hermit/bin."
57+
export PATH="${MCP_HERMIT_DIR}/bin:${PATH}"
58+
log "Updated PATH to include ${MCP_HERMIT_DIR}/bin."
4959

5060

5161
# Verify hermit installation

ui/desktop/src/main.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,14 @@ const getBundledConfig = (): BundledConfig => {
496496
const { defaultProvider, defaultModel, predefinedModels, baseUrlShare, version } =
497497
getBundledConfig();
498498

499+
const resolveGoosePathRoot = (): string | undefined => {
500+
const pathRoot = process.env.GOOSE_PATH_ROOT?.trim();
501+
if (pathRoot) {
502+
return expandTilde(pathRoot);
503+
}
504+
return undefined;
505+
};
506+
499507
const GENERATED_SECRET = crypto.randomBytes(32).toString('hex');
500508

501509
const getServerSecret = (settings: Settings): string => {
@@ -513,6 +521,7 @@ let appConfig = {
513521
GOOSE_DEFAULT_MODEL: defaultModel,
514522
GOOSE_PREDEFINED_MODELS: predefinedModels,
515523
GOOSE_API_HOST: 'https://localhost',
524+
GOOSE_PATH_ROOT: resolveGoosePathRoot(),
516525
GOOSE_WORKING_DIR: '',
517526
// If GOOSE_ALLOWLIST_WARNING env var is not set, defaults to false (strict blocking mode)
518527
GOOSE_ALLOWLIST_WARNING: process.env.GOOSE_ALLOWLIST_WARNING === 'true',
@@ -554,7 +563,9 @@ const createChat = async (app: App, options: CreateChatOptions = {}) => {
554563
const goosedResult = await startGoosed({
555564
serverSecret,
556565
dir: dir || os.homedir(),
557-
env: { GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT },
566+
env: {
567+
GOOSE_PATH_ROOT: appConfig.GOOSE_PATH_ROOT as string | undefined,
568+
},
558569
externalGoosed: settings.externalGoosed,
559570
isPackaged: app.isPackaged,
560571
resourcesPath: app.isPackaged ? process.resourcesPath : undefined,

ui/desktop/src/recipe/recipe_management.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export const convertToLocaleDateString = (lastModified: string): string => {
4343

4444
export const getStorageDirectory = (isGlobal: boolean): string => {
4545
if (isGlobal) {
46+
const pathRoot = window.appConfig.get('GOOSE_PATH_ROOT') as string | undefined;
47+
if (pathRoot) {
48+
return `${pathRoot}/config/recipes`;
49+
}
50+
const configDir = window.appConfig.get('GOOSE_CONFIG_DIR') as string | undefined;
51+
if (configDir) {
52+
return `${configDir}/recipes`;
53+
}
4654
return '~/.config/goose/recipes';
4755
} else {
4856
// For directory recipes, build absolute path using working directory

0 commit comments

Comments
 (0)