Skip to content
Merged
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
5 changes: 5 additions & 0 deletions pkg/repos/runtimes/busybox/busybox.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

runtimeEnv "github.com/gptscript-ai/gptscript/pkg/env"
"github.com/gptscript-ai/gptscript/pkg/hash"
Expand All @@ -27,6 +28,7 @@ var releasesData []byte
const downloadURL = "https://github.com/gptscript-ai/busybox-w32/releases/download/%s"

type Runtime struct {
runtimeSetupLock sync.Mutex
}

func (r *Runtime) ID() string {
Expand Down Expand Up @@ -75,6 +77,9 @@ func (r *Runtime) getReleaseAndDigest() (string, string, error) {
}

func (r *Runtime) getRuntime(ctx context.Context, cwd string) (string, error) {
r.runtimeSetupLock.Lock()
defer r.runtimeSetupLock.Unlock()

url, sha, err := r.getReleaseAndDigest()
if err != nil {
return "", err
Expand Down
6 changes: 6 additions & 0 deletions pkg/repos/runtimes/golang/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

"github.com/gptscript-ai/gptscript/pkg/config"
"github.com/gptscript-ai/gptscript/pkg/debugcmd"
Expand All @@ -34,6 +35,8 @@ const downloadURL = "https://go.dev/dl/"
type Runtime struct {
// version something like "1.22.1"
Version string

runtimeSetupLock sync.Mutex
}

func (r *Runtime) ID() string {
Expand Down Expand Up @@ -355,6 +358,9 @@ func (r *Runtime) binDir(rel string) string {
}

func (r *Runtime) getRuntime(ctx context.Context, cwd string) (string, error) {
r.runtimeSetupLock.Lock()
defer r.runtimeSetupLock.Unlock()

url, sha, err := r.getReleaseAndDigest()
if err != nil {
return "", err
Expand Down
6 changes: 6 additions & 0 deletions pkg/repos/runtimes/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

"github.com/gptscript-ai/gptscript/pkg/debugcmd"
runtimeEnv "github.com/gptscript-ai/gptscript/pkg/env"
Expand All @@ -34,6 +35,8 @@ type Runtime struct {
Version string
// If true this is the version that will be used for python or python3
Default bool

runtimeSetupLock sync.Mutex
}

func (r *Runtime) ID() string {
Expand Down Expand Up @@ -175,6 +178,9 @@ func (r *Runtime) binDir(rel string) (string, error) {
}

func (r *Runtime) getRuntime(ctx context.Context, cwd string) (string, error) {
r.runtimeSetupLock.Lock()
defer r.runtimeSetupLock.Unlock()

url, sha, err := r.getReleaseAndDigest()
if err != nil {
return "", err
Expand Down
6 changes: 6 additions & 0 deletions pkg/repos/runtimes/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path/filepath"
"runtime"
"sync"

"github.com/gptscript-ai/gptscript/pkg/debugcmd"
runtimeEnv "github.com/gptscript-ai/gptscript/pkg/env"
Expand Down Expand Up @@ -42,6 +43,8 @@ type Runtime struct {
Version string
// If true this is the version that will be used for python or python3
Default bool

runtimeSetupLock sync.Mutex
}

func (r *Runtime) ID() string {
Expand Down Expand Up @@ -234,6 +237,9 @@ func (r *Runtime) setupUV(ctx context.Context, tmp string) error {
}

func (r *Runtime) getRuntime(ctx context.Context, cwd string) (string, error) {
r.runtimeSetupLock.Lock()
defer r.runtimeSetupLock.Unlock()

url, sha, err := r.getReleaseAndDigest()
if err != nil {
return "", err
Expand Down