magpie installs a subscription's CLI at sign-in with its vendor's `curl … | bash` (internal/provider/install.go: Cursor, Devin, Grok Build). The distroless image had no curl and no /usr/bin/env (the installers' shebang), so that install couldn't run there, and only Grok Build had a native fallback. bborn2 reported that a Cursor CLI installed by hand failed with "cannot execute: required file not found". The image is now debian:12-slim with ca-certificates and curl. It keeps the nonroot user at uid/gid 65532, HOME and XDG under /config, the healthcheck, and magpie on PATH. Size: 157MB against 82MB for origin/main's image, both built here on arm64. Running a feature magpie offers is worth the 75MB. Changed in review: dropped the branch's GOPROXY build arg, a separate goal. The comments in install.go and install_test.go that said the image has no curl now say "had". docs/reference.md and the site's Docker page (en, zh, ja) say Debian with bash and curl instead of distroless with busybox. Run, with OrbStack's docker: - docker build of this tree and of d783df46c's Dockerfile: 157MB vs 82MB. - docker run of the new image: health "healthy", user nonroot (id 65532). `curl https://cursor.com/install -fsS | bash` exit 0, then `~/.local/bin/cursor-agent --version` printed 2026.10.16-e3cb207. Devin's install.sh installed devin v3000.11.92 (its trailing `devin setup` said "Login canceled" with no terminal, as on any host). `devin --version` printed 3000.11.92. bash and `magpie version` run. - Old image: `which curl` finds none, and /usr/bin/env doesn't exist. - A volume written by the old image (file owned 65532) was read and written by the new image. - gofmt -l clean; go vet darwin, linux (nogui) and windows clean. - Full `go test -tags nogui -timeout 45m ./...`: every package ok except internal/agent and internal/gateway, which timed out at 45m mid-test (TestConnectSaysHow, TestLargeRequestEndpoints) under a load average of about 200 from parallel suites. This commit changes no code those packages build, only comments in internal/provider, which passed (992s), so they weren't rerun. Not tried: a Grok Build install inside the image, and a full in-magpie Cursor/Devin sign-in with a real account in the container. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
3.8 KiB
Go
120 lines
3.8 KiB
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/testenv"
|
|
)
|
|
|
|
// an installer that fails says so, and how to install it by hand: Devin's
|
|
// plugin signs in through the CLI, which is installed first
|
|
func TestSignInInstallFails(t *testing.T) {
|
|
claudeHome(t)
|
|
oldExe := DevinExecutable
|
|
DevinExecutable = func() string { return "" }
|
|
t.Cleanup(func() { DevinExecutable = oldExe })
|
|
oldRun := runInstaller
|
|
runInstaller = func(ctx context.Context, c agentCLI) ([]byte, error) {
|
|
return []byte("downloading…\n\x1b[0;31mError: Failed to download\x1b[0m\n"), errors.New("exit status 1")
|
|
}
|
|
t.Cleanup(func() { runInstaller = oldRun })
|
|
|
|
st, err := StartPluginSignIn("devin", 0, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
st = waitPast(t, st.ID, "installing")
|
|
if st.State != "failed" || !strings.Contains(st.Error, "Error: Failed to download") || !strings.Contains(st.Error, "install it yourself") {
|
|
t.Fatalf("state %+v", st)
|
|
}
|
|
}
|
|
|
|
// on Windows the vendor's one-liner reaches PowerShell on stdin, never on
|
|
// its command line: Microsoft Defender took "powershell … -Command irm
|
|
// https://static.devin.ai/cli/setup.ps1 | iex" for a Trojan
|
|
// (Trojan:Win32/Commando.A!ml) and stopped it before it ran, so Devin's
|
|
// sign-in failed with "fork/exec …\powershell.exe: Access is denied"
|
|
func TestWindowsInstallerNotOnCommandLine(t *testing.T) {
|
|
if runtime.GOOS != "windows" {
|
|
t.Skip("PowerShell's command line is Windows'")
|
|
}
|
|
c := agentCLI{Name: "Probe CLI", ps: "Write-Output ([Environment]::CommandLine); exit 7"}
|
|
out, err := runInstaller(context.Background(), c)
|
|
var ee *exec.ExitError
|
|
if !errors.As(err, &ee) || ee.ExitCode() != 7 {
|
|
t.Fatalf("the installer's exit: %v (output %q)", err, out)
|
|
}
|
|
line := lastLine(out)
|
|
if !strings.Contains(strings.ToLower(line), "powershell") {
|
|
t.Fatalf("the installer didn't print PowerShell's command line: %q", out)
|
|
}
|
|
if strings.Contains(line, "Write-Output") {
|
|
t.Fatalf("PowerShell's command line carries the installer: %s", line)
|
|
}
|
|
}
|
|
|
|
// canceled while installing: the sign-in never starts
|
|
func TestSignInCanceledWhileInstalling(t *testing.T) {
|
|
claudeHome(t)
|
|
oldExe := DevinExecutable
|
|
DevinExecutable = func() string { return "" }
|
|
t.Cleanup(func() { DevinExecutable = oldExe })
|
|
stopped := make(chan struct{})
|
|
oldRun := runInstaller
|
|
runInstaller = func(ctx context.Context, c agentCLI) ([]byte, error) {
|
|
<-ctx.Done()
|
|
close(stopped)
|
|
return nil, ctx.Err()
|
|
}
|
|
t.Cleanup(func() { runInstaller = oldRun })
|
|
|
|
st, _ := StartPluginSignIn("devin", 0, nil)
|
|
CancelSignIn(st.ID)
|
|
select {
|
|
case <-stopped:
|
|
case <-time.After(5 * time.Second):
|
|
t.Fatal("the installer went on")
|
|
}
|
|
if st, _ = SignInStatus(st.ID); st.State != "canceled" {
|
|
t.Fatalf("state %+v", st)
|
|
}
|
|
}
|
|
|
|
func waitPast(t *testing.T, id, state string) SignInState {
|
|
t.Helper()
|
|
for end := time.Now().Add(signInDeadline); time.Now().Before(end); time.Sleep(20 * time.Millisecond) {
|
|
if st, _ := SignInStatus(id); st.State != state {
|
|
return st
|
|
}
|
|
}
|
|
t.Fatalf("still %s after %s", state, signInDeadline)
|
|
return SignInState{}
|
|
}
|
|
|
|
// magpie's Docker image had bash and busybox's wget but no curl, which every
|
|
// vendor's one-liner downloads with: there the native installer is used
|
|
func TestShellInstallerNeedsCurl(t *testing.T) {
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("the shell installer is for macOS and Linux")
|
|
}
|
|
bin := t.TempDir()
|
|
for _, p := range []string{"bash", "wget"} {
|
|
testenv.Program(t, filepath.Join(bin, p), "#!/bin/sh\n")
|
|
}
|
|
t.Setenv("PATH", bin)
|
|
if shellInstallerRuns() {
|
|
t.Fatal("the shell installer runs with bash and wget, without curl")
|
|
}
|
|
testenv.Program(t, filepath.Join(bin, "curl"), "#!/bin/sh\n")
|
|
if !shellInstallerRuns() {
|
|
t.Fatal("the shell installer doesn't run with bash and curl")
|
|
}
|
|
}
|