Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ brew install brevdev/homebrew-brev/brev
### Linux

```bash
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/brevdev/brev-cli/main/bin/install-latest.sh)"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/brevdev/brev-cli/main/bin/install-latest.sh)"
```

### Windows
Expand All @@ -30,7 +30,7 @@ Brev is supported on windows currently through the Windows Subsystem for Linux (
Once you have WSL installed and configured, you can install Brev by running the following command in your terminal:

```bash
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/brevdev/brev-cli/main/bin/install-latest.sh)"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/brevdev/brev-cli/main/bin/install-latest.sh)"
```

### From conda-forge
Expand Down
23 changes: 20 additions & 3 deletions bin/install-latest-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,24 @@ curl -L "${DOWNLOAD_URL}" -o "${TMP_DIR}/$(basename "${DOWNLOAD_URL}")"
ARCHIVE_FILE="$(find "${TMP_DIR}" -name "brev*.tar.gz" -type f)"
tar -xzf "${ARCHIVE_FILE}" -C "${TMP_DIR}"

# Install the binary to system location
sudo mv "${TMP_DIR}/brev" /usr/local/bin/brev
sudo chmod +x /usr/local/bin/brev
# Install the binary to user-local location (no sudo required)
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
mv "${TMP_DIR}/brev" "${INSTALL_DIR}/brev"
chmod +x "${INSTALL_DIR}/brev"

echo "Successfully installed brev CLI to ${INSTALL_DIR}/brev"

# Warn if the install directory is not in PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "WARNING: ${INSTALL_DIR} is not in your PATH."
echo "Add it by running:"
echo ""
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc && source ~/.bashrc"
echo ""
;;
esac

23 changes: 19 additions & 4 deletions bin/install-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,23 @@ trap 'rm -rf "${TMP_DIR}"' EXIT
curl -sL "${DOWNLOAD_URL}" -o "${TMP_DIR}/brev.tar.gz"
tar -xzf "${TMP_DIR}/brev.tar.gz" -C "${TMP_DIR}"

# Install the binary to system location
sudo mv "${TMP_DIR}/brev" /usr/local/bin/brev
sudo chmod +x /usr/local/bin/brev
# Install the binary to user-local location (no sudo required)
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
mv "${TMP_DIR}/brev" "${INSTALL_DIR}/brev"
chmod +x "${INSTALL_DIR}/brev"

echo "Successfully installed brev CLI to /usr/local/bin/brev"
echo "Successfully installed brev CLI to ${INSTALL_DIR}/brev"

# Warn if the install directory is not in PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "WARNING: ${INSTALL_DIR} is not in your PATH."
echo "Add it by running:"
echo ""
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc && source ~/.bashrc"
echo ""
;;
esac
2 changes: 1 addition & 1 deletion pkg/cmd/upgrade/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (SystemUpgrader) UpgradeViaBrew(t *terminal.Terminal) error {
return nil
}

// UpgradeViaInstallScript runs the upstream install-latest.sh script via sudo.
// UpgradeViaInstallScript runs the upstream install-latest.sh script.
func (SystemUpgrader) UpgradeViaInstallScript(t *terminal.Terminal) error {
t.Vprintf("Running: bash -c \"$(curl -fsSL %s)\"\n", installScriptURL)
t.Vprint("")
Expand Down
10 changes: 4 additions & 6 deletions pkg/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/brevdev/brev-cli/pkg/cmd/register"
"github.com/brevdev/brev-cli/pkg/cmd/version"
"github.com/brevdev/brev-cli/pkg/store"
"github.com/brevdev/brev-cli/pkg/sudo"
"github.com/brevdev/brev-cli/pkg/terminal"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -43,7 +42,6 @@ type upgradeDeps struct {
detector Detector
upgrader Upgrader
confirmer terminal.Confirmer
gater sudo.Gater
skillInstaller SkillInstaller
}

Expand All @@ -52,7 +50,6 @@ func defaultUpgradeDeps() upgradeDeps {
detector: SystemDetector{},
upgrader: SystemUpgrader{},
confirmer: register.TerminalPrompter{},
gater: sudo.Default,
skillInstaller: defaultSkillInstaller{},
}
}
Expand Down Expand Up @@ -146,11 +143,12 @@ func upgradeViaBrew(t *terminal.Terminal, deps upgradeDeps) (bool, error) {

func upgradeViaDirect(t *terminal.Terminal, deps upgradeDeps) (bool, error) {
t.Vprint("Detected install method: direct binary install")
t.Vprint("This will download the latest release and install it to /usr/local/bin/brev")
t.Vprint("This will download the latest release and install it to ~/.local/bin/brev")
t.Vprint("")

if err := deps.gater.Gate(t, deps.confirmer, "Upgrade", false); err != nil {
return false, fmt.Errorf("sudo issue: %w", err)
if !deps.confirmer.ConfirmYesNo("Proceed with upgrade?") {
t.Vprint("Upgrade canceled.")
return false, nil
}

t.Vprint("")
Expand Down
8 changes: 0 additions & 8 deletions pkg/cmd/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/brevdev/brev-cli/pkg/cmd/version"
"github.com/brevdev/brev-cli/pkg/store"
"github.com/brevdev/brev-cli/pkg/sudo"
"github.com/brevdev/brev-cli/pkg/terminal"
)

Expand Down Expand Up @@ -65,7 +64,6 @@ func Test_runUpgrade_AlreadyUpToDate(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand Down Expand Up @@ -94,7 +92,6 @@ func Test_runUpgrade_BrewPath(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand Down Expand Up @@ -126,7 +123,6 @@ func Test_runUpgrade_DirectPath(t *testing.T) {
detector: mockDetector{method: InstallMethodDirect},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand Down Expand Up @@ -158,7 +154,6 @@ func Test_runUpgrade_UserCancels(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: false},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand All @@ -181,7 +176,6 @@ func Test_runUpgrade_VersionCheckFails(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: &mockUpgrader{},
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: &mockSkillInstaller{},
}

Expand All @@ -204,7 +198,6 @@ func Test_runUpgrade_UpgraderFails(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand All @@ -230,7 +223,6 @@ func Test_runUpgrade_SkillInstallFailure_DoesNotFailUpgrade(t *testing.T) {
detector: mockDetector{method: InstallMethodBrew},
upgrader: upgrader,
confirmer: mockConfirmer{confirm: true},
gater: sudo.CachedGater{},
skillInstaller: skill,
}

Expand Down