Skip to content

Commit aff32e1

Browse files
authored
[offline] Allow devbox to work offline if packages are already fetched (#1673)
## Summary Very basic fix. Doesn't handle all cases, but fixes run/shell. Fixes #1657 ## How was it tested? Turned off my wifi, modified `.local.lock` file to bust cache. Was able to run/shell.
1 parent 8c49985 commit aff32e1

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

.github/workflows/cli-tests.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ jobs:
5656
- uses: actions/setup-go@v4
5757
with:
5858
go-version-file: ./go.mod
59-
- name: Mount golang cache
60-
uses: actions/cache@v3
61-
with:
62-
path: |
63-
~/.cache/go-build
64-
~/go/pkg
65-
key: go-devbox-build-${{ runner.os }}-${{ hashFiles('go.sum') }}
6659
- name: Build devbox
6760
run: go build -o dist/devbox ./cmd/devbox
6861
- name: Upload devbox artifact

internal/impl/devbox.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,10 @@ func (d *Devbox) ensurePackagesAreInstalledAndComputeEnv(
953953

954954
// When ensurePackagesAreInstalled is called with ensure=true, it always
955955
// returns early if the lockfile is up to date. So we don't need to check here
956-
if err := d.ensurePackagesAreInstalled(ctx, ensure); err != nil {
956+
if err := d.ensurePackagesAreInstalled(ctx, ensure); err != nil && !strings.Contains(err.Error(), "no such host") {
957957
return nil, err
958+
} else if err != nil {
959+
ux.Fwarning(d.stderr, "Error connecting to the internet. Will attempt to use cached environment.\n")
958960
}
959961

960962
// Since ensurePackagesAreInstalled calls computeNixEnv when not up do date,

0 commit comments

Comments
 (0)