Skip to content

Commit fa5bdad

Browse files
tonychang04claude
andauthored
fix(install): symlink into an on-PATH dir so insta runs immediately (#41)
Root cause of 'command not found: insta' after the one-liner: we installed only to ~/.insta/bin (never on PATH), so the recommended 'curl … | sh && insta project create' chain called insta in a shell whose PATH the piped script can't change. Railway avoids this by installing where PATH already looks (and sudo-escalating if needed). Now: after installing to ~/.insta/bin, symlink into a writable on-PATH dir (/usr/local/bin, else ~/.local/bin) so bare 'insta' resolves in the same shell with no reload; fall back to profile-append + an explicit this-shell export only when no such dir exists. Verified live: fresh install → 'command -v insta' resolves, v0.0.13, no manual step. Claude-Session: https://claude.ai/code/session_01GMbAe5K1RfwaAcge5inX7P Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 4a9875f commit fa5bdad

1 file changed

Lines changed: 34 additions & 9 deletions

File tree

install.sh

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ echo "✓ installed to $INSTALL_DIR/$BIN"
119119
"$INSTALL_DIR/$BIN" --version 2>/dev/null || true
120120
fi
121121

122+
# ---- make `insta` immediately runnable in THIS shell ----
123+
# The recommended one-liner is `curl … | sh && insta …`, so the binary must be callable in the
124+
# current shell right away — a piped script can't edit the parent's PATH. If a directory that's
125+
# already on PATH is writable (macOS /usr/local/bin, or ~/.local/bin), symlink there so `insta`
126+
# just works with no profile reload. (This is why installing only to ~/.insta/bin fails.)
127+
if [ "${SKIP_DOWNLOAD:-0}" != "1" ] || [ ! -e "$INSTALL_DIR/$BIN" ]; then :; fi
128+
ON_PATH=0
129+
case ":${PATH}:" in *":$INSTALL_DIR:"*) ON_PATH=1 ;; esac
130+
LINKED=""
131+
if [ "$ON_PATH" != "1" ]; then
132+
for d in /usr/local/bin "$HOME/.local/bin"; do
133+
case ":${PATH}:" in *":$d:"*) ;; *) continue ;; esac # must already be on PATH
134+
[ -d "$d" ] && [ -w "$d" ] || continue # …and writable (no sudo)
135+
ln -sf "$INSTALL_DIR/$BIN" "$d/$BIN" && LINKED="$d/$BIN" && break
136+
done
137+
fi
138+
122139
# ---- agent setup (--agents) ----
123140
if [ "$AGENTS" = "1" ]; then
124141
echo
@@ -130,15 +147,23 @@ if [ "$AGENTS" = "1" ]; then
130147
fi
131148
fi
132149

133-
# ---- PATH hint ----
134-
case ":${PATH}:" in
135-
*":$INSTALL_DIR:"*) ;;
136-
*)
137-
echo
138-
echo "Add $BIN to your PATH by adding this to your shell profile (~/.zshrc, ~/.bashrc):"
139-
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
140-
;;
141-
esac
150+
# ---- PATH: confirm reachable, or tell the user exactly how (incl. THIS shell) ----
151+
if [ "$ON_PATH" = "1" ]; then
152+
: # already on PATH
153+
elif [ -n "$LINKED" ]; then
154+
echo "✓ linked → $LINKED (on your PATH)"
155+
command -v hash >/dev/null 2>&1 && hash -r 2>/dev/null || true # drop any cached 'not found'
156+
else
157+
# No writable PATH dir — persist for new shells, and make THIS shell work now.
158+
for rc in "$HOME/.zshrc" "$HOME/.bashrc"; do
159+
[ -e "$rc" ] || continue
160+
grep -q "$INSTALL_DIR" "$rc" 2>/dev/null || printf '\nexport PATH="%s:$PATH"\n' "$INSTALL_DIR" >> "$rc"
161+
done
162+
echo
163+
echo "Added $BIN to your PATH for new shells. For THIS shell, run:"
164+
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
165+
echo "(the recommended \`… | sh && insta …\` one-liner needs \`insta\` on PATH — the line above enables it here)"
166+
fi
142167

143168

144169
# ---- next steps (the 3-command wow: real infra, then a full isolated clone of it) ----

0 commit comments

Comments
 (0)