Skip to content

Fix various things in sg install

Administrator requested to merge mrn+jh/fix-sg-stuff into main

Created by: mrnugget

This does a bunch of things.

Fix sg updates getting confused by sg installed in multiple paths

This solves this problem:

  1. ./dev/sg/install.sh installs sg into $GOBIN
  2. bootstraph.sh && sg install puts it into a) on macOS: ~/.sg/ b) on Linux: ~/.local/bin/sg
  3. sg update (auto-triggered by sg start) puts it in $GOBIN
  4. which sg still points to old sg
  5. endless loop of auto-updates

It fixes it by changing sg update to move the newly-downloaded sg to the path of the currently executed sg.

And we also updated the path used in sg ... auto-updating to use the path of the currently-executing sg.

Do not fail if auto-update fails

Since we now rely on prebuilt binaries and downloading them from GitHub we don't want to fail sg start etc when GitHub is down. So we don't exit when checking version && auto-updating fails.

Removes multiple install destination from sg

This deprecates ./dev/sg/install.sh as a way to install sg and advertises for downloading the binary.

Why? Because ./dev/sg/install.sh installs sg into $GOBIN, which is not the "canonical" install location used by sg install. We could've made ./dev/sg/install.sh use sg install instead, but then we'd have to make sg install idempotent. Instead we decided to deprecate install.sh altogether so we only have 2 official ways to install/update sg:

  1. curl ... |sh to install sg
  2. sg update to update to latest prebuilt binary

If you're an sg developer, you can still use go build in ./dev/sg.

Bring the "new sg version available" banner into 2022

See diff. New banner is tasty.

Follow-ups

  • Detect new versions on GitHub, not locally
  • Add something unique to sg help or sg version that tells us that this sg is Sourcegraph's sg and not the sg thing on Linux

Test plan

  • Tested this locally by running sg install, sg update, playing around with $PATH etc.

Merge request reports

Loading