Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
carlotm opened this issue Apr 9, 2024 · 4 comments · Fixed by #1985
Closed

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

carlotm opened this issue Apr 9, 2024 · 4 comments · Fixed by #1985
Labels
bug Something isn't working triage Issue needs triage

Comments

@carlotm
Copy link

carlotm commented Apr 9, 2024

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 carlotm added bug Something isn't working triage Issue needs triage labels Apr 9, 2024
@carlotm
Copy link
Author

carlotm commented Apr 10, 2024

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
Copy link
Collaborator

gcurtis commented Apr 10, 2024

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
Copy link
Author

carlotm commented Apr 10, 2024

@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
Copy link
Contributor

@carlotm the issue is my original fix in #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:

  • Devbox uses nix cache to install packages fast. It checks if stuff is in the cache which requires a network request.
  • Whenever your state is stale (this can happen when you change devbox.json or when you update devbox versions), we recompute everything, including checking the cache again to verify the packages match your environment.

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, #1985 is an easy solution that would allow you to continue working in offline mode if DNS resolution fails.

mikeland73 added a commit that referenced this issue Apr 11, 2024
## Summary

Fixes #1977

(with another hack).

Unfortunately the way we structure our flake makes it really difficult
to remove our network requests (when state is stale). Ideally, the flake
can be built off of local only nix store references, but that's a much
bigger project.

In the meantime, this is a quick hack that fixes issue above.

## How was it tested?

Added synthetic error that returns `connection refused` in the message.
Ensures I was still able to run/shell with a stale state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs triage
Development

Successfully merging a pull request may close this issue.

3 participants