Fix various things in sg install
Created by: mrnugget
This does a bunch of things.
sg
installed in multiple paths
Fix sg updates getting confused by This solves this problem:
-
./dev/sg/install.sh
installssg
into$GOBIN
-
bootstraph.sh && sg install
puts it into a) on macOS:~/.sg/
b) on Linux:~/.local/bin/sg
-
sg update
(auto-triggered bysg start
) puts it in$GOBIN
-
which sg
still points to oldsg
- 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.
sg
Removes multiple install destination from 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
:
-
curl ... |sh
to installsg
-
sg update
to update to latest prebuilt binary
If you're an sg
developer, you can still use go build
in ./dev/sg
.
sg
version available" banner into 2022
Bring the "new See diff. New banner is tasty.
Follow-ups
- Detect new versions on GitHub, not locally
- Add something unique to
sg help
orsg version
that tells us that thissg
is Sourcegraph'ssg
and not thesg
thing on Linux
Test plan
- Tested this locally by running
sg install
,sg update
, playing around with$PATH
etc.