Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ help_text="Options
--agents
Install or reuse the Railway CLI, then configure Railway agent support

--remote
When used with --agents, configure the remote HTTP MCP server at
mcp.railway.com instead of the local stdio server

-r, --remove
Uninstall railway

Expand Down Expand Up @@ -393,6 +397,7 @@ is_build_available() {
UNINSTALL=0
HELP=0
AGENTS=0
REMOTE=0
RAILWAY_HOME_DIR=""
RAILWAY_ENV_FILE=""
RAILWAY_FISH_ENV_FILE=""
Expand Down Expand Up @@ -477,6 +482,10 @@ while [ "$#" -gt 0 ]; do
AGENTS=1
shift 1
;;
--remote)
REMOTE=1
shift 1
;;
-h | --help)
HELP=1
shift 1
Expand Down Expand Up @@ -520,6 +529,12 @@ else
VERBOSE=
fi

# --remote only takes effect alongside --agents (it routes setup agent to the
# hosted MCP server). Warn loudly rather than silently no-op.
if [ "$REMOTE" = 1 ] && [ "$AGENTS" != 1 ]; then
warn "--remote has no effect without --agents. Re-run with both flags to configure remote MCP."
fi

write_env_files() {
local quoted_railway_home
local fish_railway_home
Expand Down Expand Up @@ -887,6 +902,7 @@ warn_existing_path_conflict() {
run_agent_setup() {
local railway_bin="$1"
local yes=""
local remote=""

if [ -z "${RAILWAY_INSTALL_REQUEST_ID-}" ]; then
RAILWAY_INSTALL_REQUEST_ID="install_$(od -vAn -N16 -tx1 < /dev/urandom | tr -d ' \n')"
Expand All @@ -897,6 +913,10 @@ run_agent_setup() {
yes="-y"
fi

if [ "$REMOTE" = 1 ]; then
remote="--remote"
fi

if [ -t 0 ] && [ -z "${FORCE-}" ]; then
if "$railway_bin" whoami >/dev/null 2>&1; then
info "Already logged in to Railway."
Expand All @@ -906,7 +926,7 @@ run_agent_setup() {
fi
fi

"$railway_bin" setup agent $yes
"$railway_bin" setup agent $yes $remote

if ! "$railway_bin" whoami >/dev/null 2>&1; then
warn "Next: run '$railway_bin login' to finish setup (opens a browser)."
Expand Down Expand Up @@ -993,6 +1013,15 @@ if [ "$AGENTS" = 1 ] && has railway; then
esac

if [ "$BREW_INSTALL" = 1 ]; then
if [ "$REMOTE" = 1 ]; then
# --remote was added in a newer release. Continuing with an older brewed
# CLI would call `setup agent --remote` and fail with an unrecognized-arg
# error after we already told the user we were continuing. Refuse early.
error "Railway CLI was installed via Homebrew (version $CURRENT_VERSION)."
error "The --remote flag requires Railway CLI $RAILWAY_VERSION or newer."
error "Run 'brew upgrade railway' first, then re-run cli.new --agents --remote."
exit 1
fi
warn "Railway CLI was installed via Homebrew."
warn "Run 'brew upgrade railway' to update from $CURRENT_VERSION to $RAILWAY_VERSION, then re-run cli.new --agents."
info "Continuing with $CURRENT_VERSION."
Expand Down
Loading