jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
8.2k stars 192 forks source link

Unable to activate a shell because of a network error. I am unable to work. #1977

Closed carlotm closed 4 months ago

carlotm commented 4 months ago

What happened?

This morning I tried to activate a shell (devbox shell), the same shell I activate every day at work.

I got this error:

Info: Ensuring packages are installed.
Error: Head "https://cache.nixos.org/frsl3935sgp53hdgmmknhbl33d4fb7nn.narinfo": dial tcp: lookup cache.nixos.org on [::1]:53: read udp [::1]:50731->[::1]:53: read: connection refused

I have to mention I can wget that url correctly.

I believe one should be able to use devbox offline without issues if packages are already downloaded.

I opened an issue some time ago, which was promptly resolved (#1657) I don't know if this is the same issue, but it's preventing me from being able to work, which is quite annoying, honestly.

Cheers! Carlo

Command

shell

devbox.json

{
  "packages": [
    "glibcLocales@latest",
    "nodejs_latest@18.2.0",
    "elixir_1_15@1.15.4",
    "solr@8.6.3",
    "postgresql@latest",
    "elixir-ls@latest",
    "erlang@latest"
  ]
}

Devbox version

0.10.4

Nix version

nix (Nix) 2.17.1

What system does this bug occur on?

Linux (x86-64)

Debug logs

> DEVBOX_DEBUG=1 devbox shell
2024/04/09 11:37:42 findProjectDir: path is 
2024/04/09 11:37:42 finding devbox config in dir: /home/carloratm/w/oha
2024/04/09 11:37:42 findProjectDir: path is 
2024/04/09 11:37:42 finding devbox config in dir: /home/carloratm/w/oha
2024/04/09 11:37:42 findProjectDir: path is 
2024/04/09 11:37:42 finding devbox config in dir: /home/carloratm/w/oha
Info: Ensuring packages are installed.
2024/04/09 11:37:42 Creating files for package "postgresql@latest" create files
2024/04/09 11:37:42 Creating file "/home/carloratm/w/oha/.devbox/virtenv/postgresql/process-compose.yaml" from contentPath: "postgresql/process-compose.yaml"
Error: Head "https://cache.nixos.org/61aw43qsfyadjc7md824imz993r3yrsk.narinfo": dial tcp: lookup cache.nixos.org on [::1]:53: read udp [::1]:43537->[::1]:53: read: connection refused

2024/04/09 11:37:42 
ExecutionID:807a93a75920460d89bf724ce78362e3
<nil>
2024/04/09 11:37:42 findProjectDir: path is 
2024/04/09 11:37:42 finding devbox config in dir: /home/carloratm/w/oha
carlotm commented 4 months ago

I tried removing the devbox.lock and the .devbox folder. Now the verbose output when trying to activate the shell tells this:

> DEVBOX_DEBUG=1 devbox shell
2024/04/10 09:54:46 findProjectDir: path is 
2024/04/10 09:54:46 finding devbox config in dir: /home/carloratm/w/oha
2024/04/10 09:54:46 findProjectDir: path is 
2024/04/10 09:54:46 finding devbox config in dir: /home/carloratm/w/oha
2024/04/10 09:54:46 findProjectDir: path is 
2024/04/10 09:54:46 finding devbox config in dir: /home/carloratm/w/oha
Info: Ensuring packages are installed.
2024/04/10 09:54:46 Creating files for package "postgresql@latest" create files
2024/04/10 09:54:46 Creating file "/home/carloratm/w/oha/.devbox/virtenv/postgresql/process-compose.yaml" from contentPath: "postgresql/process-compose.yaml"
Error: GET https://search.devbox.sh/v2/resolve?name=postgresql&version=latest: Get "https://search.devbox.sh/v2/resolve?name=postgresql&version=latest": dial tcp: lookup search.devbox.sh on [::1]:53: read udp [::1]:58524->[::1]:53: read: connection refused

2024/04/10 09:54:46 
ExecutionID:9d6be99f070a446b8a9cd44b3ca908e9
GET https://search.devbox.sh/v2/resolve?name=postgresql&version=latest: Get "https://search.devbox.sh/v2/resolve?name=postgresql&version=latest": dial tcp: lookup search.devbox.sh on [::1]:53: read udp [::1]:58524->[::1]:53: read: connection refused
go.jetpack.io/devbox/internal/searcher.execGet[...]
    go.jetpack.io/devbox/internal/searcher/client.go:93
go.jetpack.io/devbox/internal/searcher.(*client).ResolveV2
    go.jetpack.io/devbox/internal/searcher/client.go:83
go.jetpack.io/devbox/internal/lock.resolveV2
    go.jetpack.io/devbox/internal/lock/resolve.go:90
go.jetpack.io/devbox/internal/lock.(*File).FetchResolvedPackage
    go.jetpack.io/devbox/internal/lock/resolve.go:51
go.jetpack.io/devbox/internal/lock.(*File).Resolve
    go.jetpack.io/devbox/internal/lock/lockfile.go:81
go.jetpack.io/devbox/internal/devpkg.resolve
    go.jetpack.io/devbox/internal/devpkg/package.go:162
go.jetpack.io/devbox/internal/devpkg.newPackage.func1
    go.jetpack.io/devbox/internal/devpkg/package.go:147
go.jetpack.io/devbox/internal/devpkg.newPackage.OnceValue[...].func5
    sync/oncefunc.go:57
sync.(*Once).doSlow
    sync/once.go:74
sync.(*Once).Do
    sync/once.go:65
go.jetpack.io/devbox/internal/devpkg.newPackage.OnceValue[...].func6
    sync/oncefunc.go:62
go.jetpack.io/devbox/internal/devpkg.(*Package).PackageAttributePath
    go.jetpack.io/devbox/internal/devpkg/package.go:321
go.jetpack.io/devbox/internal/plugin.(*Manager).createFile
    go.jetpack.io/devbox/internal/plugin/plugin.go:134
go.jetpack.io/devbox/internal/plugin.(*Manager).CreateFilesForConfig
    go.jetpack.io/devbox/internal/plugin/plugin.go:103
go.jetpack.io/devbox/internal/devbox.(*Devbox).installPackages
    go.jetpack.io/devbox/internal/devbox/packages.go:390
go.jetpack.io/devbox/internal/devbox.(*Devbox).ensureStateIsUpToDate
    go.jetpack.io/devbox/internal/devbox/packages.go:263
go.jetpack.io/devbox/internal/devbox.(*Devbox).ensureStateIsUpToDateAndComputeEnv
    go.jetpack.io/devbox/internal/devbox/devbox.go:1010
go.jetpack.io/devbox/internal/devbox.(*Devbox).Shell
    go.jetpack.io/devbox/internal/devbox/devbox.go:209
go.jetpack.io/devbox/internal/boxcli.runShellCmd
    go.jetpack.io/devbox/internal/boxcli/shell.go:83
go.jetpack.io/devbox/internal/boxcli.shellCmd.func1
    go.jetpack.io/devbox/internal/boxcli/shell.go:36
github.com/spf13/cobra.(*Command).execute
    github.com/spf13/cobra@v1.8.0/command.go:983
github.com/spf13/cobra.(*Command).ExecuteC
    github.com/spf13/cobra@v1.8.0/command.go:1115
github.com/spf13/cobra.(*Command).Execute
    github.com/spf13/cobra@v1.8.0/command.go:1039
go.jetpack.io/devbox/internal/boxcli/midcobra.(*midcobraExecutable).Execute
    go.jetpack.io/devbox/internal/boxcli/midcobra/midcobra.go:61
go.jetpack.io/devbox/internal/boxcli.Execute
    go.jetpack.io/devbox/internal/boxcli/root.go:114
go.jetpack.io/devbox/internal/boxcli.Main
    go.jetpack.io/devbox/internal/boxcli/root.go:137
main.main
    ./main.go:11
runtime.main
    runtime/proc.go:271
runtime.goexit
    runtime/asm_amd64.s:1695
2024/04/10 09:54:46 findProjectDir: path is 
2024/04/10 09:54:46 finding devbox config in dir: /home/carloratm/w/oha

Hope this helps

gcurtis commented 4 months ago

Hey @carlotm, you're right that we shouldn't be preventing a shell if packages are already downloaded. I think there are two things I'll look into here:

  1. Ensure that we don't error out if there's a network error.
  2. It looks like Devbox is encountering a DNS error, yet curl/wget work ok.

For the second one, are you connected to a VPN? Do you know how you have DNS configured? It looks like Go is trying port 53 on localhost, which doesn't have anything listening. I think Go now defaults to not using glibc for lookups, which could explain why curl works but Devbox doesn't.

carlotm commented 4 months ago

@gcurtis

Thank you, I double checked and indeed my dns wasn't resolving correctly, (curl tricked me).

I am still not sure why devbox needs to fetch anything remotely if I have the packages already installed, but that's too advanced for me to understand.

Cheers!

mikeland73 commented 4 months ago

@carlotm the issue is my original fix in https://github.com/jetify-com/devbox/issues/1657 was just a hack. unfortunately my follow up fix is a hack as well (check description for a bit of what is going on). Theses fixes are mostly bandaids that catch some network failures, but not all.

In terms of why it works this way, the (kinda) short answer is:

We don't need to actually check the remote cache because the lockfile has enough information to check the local cache on your machine. But doing this is a much bigger change that would require some rearchitecting. In the meantime, https://github.com/jetify-com/devbox/pull/1985 is an easy solution that would allow you to continue working in offline mode if DNS resolution fails.