edgedb-cli icon indicating copy to clipboard operation
edgedb-cli copied to clipboard

edgedb error: failed to fetch JSON at URL `.jsonindexes/aarch64-apple-darwin.json`

Open well1791 opened this issue 1 year ago • 17 comments

  • EdgeDB Version: edgedb error: project is not initialized
  • EdgeDB CLI Version: EdgeDB CLI 3.4.0+4d95a2c
  • OS Version: MacOS Ventura 13.4 (22F66) - Apple M1 Pro

Screenshot

image

Description

Error message

Found `edgedb.toml` in /Users/wmendoza/Code/krew.git/wt/1/krew
Initializing project...
Specify the name of EdgeDB instance to use with this project [default: krew]:
> mine
Checking EdgeDB versions...
edgedb error
  : failed to fetch JSON at URL: https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json
  : error sending request for url (https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json)
  : error trying to connect
  : tcp connect error
  : Operation not permitted (os error 1)
  : error trying to connect
  : tcp connect error
  : Operation not permitted (os error 1)
  : tcp connect error
  : Operation not permitted (os error 1)
  : Operation not permitted (os error 1)

Ok, I've tried uninstalling (removing) all edgedb references then installing them again, I've turned off the firewall just for this operation, I've been running this edgedb project init on fish (default sh), zsh, and bash, and now I'm running out of ideas.

Steps to Reproduce:

  1. edgedb project init

EDIT:

For context, the first time I installed it and ran edgedb project init it worked good, then by mistake I created two projects with similar name, however, I decided to remove both of them so first I did edgedb instance list to get the names and then edgedb instance destroy --force -I name1 and the same for the other one, then I tried edgedb project init again but this time I got the error in the description.

well1791 avatar Aug 15 '23 18:08 well1791

I'm just starting to look at the CLI myself so still a bit unfamiliar but here are some questions and thoughts:

  • I assume this error is happening right away? Looks like there is a 60 second timeout but if a connection is stalled there should be some output after 2 seconds which I don't see in your screenshot.
  • Do you see anything interesting if you type edgedb instance logs -I <instance_name>?
  • I had some weird behavior myself in the past when reinitializing a project as there was an edgedb.toml in an unrelated parent directory which confused the client. I can see in the code that it does do a search for all parent directories for edgedb.toml if it can't find it in the current directory. Deleting edgedb.toml got rid of the confusion in this case.

Dhghomon avatar Aug 15 '23 22:08 Dhghomon

I assume this error is happening right away? Looks like there is a 60 second timeout but if a connection is stalled there should be some output after 2 seconds which I don't see in your screenshot.

That's correct there's no waiting, it's like a direct reply from the command

Do you see anything interesting if you type edgedb instance logs -I <instance_name>?

Unfortunately I cannot run such command because I have no instances available, I won't be able to have instances unless I run the edgedb project init command first

Deleting edgedb.toml got rid of the confusion in this case.

Interesting, I'll try it and let you know how it goes. Also, thanks for your reply 🙇‍♂️

well1791 avatar Aug 16 '23 19:08 well1791

Hey @Dhghomon, I have a question, do you if know there's a flag that allow the command log a stack trace of the error or anything that provides more context on the bug's nature?

well1791 avatar Aug 16 '23 19:08 well1791

Not that I know of: the only part where I see a backtrace in the code is inside interrupt.rs which is for something else. This does give a sort of trace though as each error gets passed on. The last function in the errors is this one which races the request against a 2-second timer which is why I suspected it was happening right away,

https://github.com/edgedb/edgedb-cli/blob/master/src/portable/repository.rs#L185

and the part that fails is inside here, I assume at line 171.

https://github.com/edgedb/edgedb-cli/blob/master/src/portable/repository.rs#L169

The rest of the errors are from inside the reqwest crate which is the client making the request, and that's the puzzling part. I guess the tcp error might have to do with the CLI being confused by the duplicate names used before. Maybe I can replicate it though I'm on Windows so tough to say.

Did deleting edgedb.toml solve the issue though?

Dhghomon avatar Aug 17 '23 06:08 Dhghomon

Sorry, I forgot to mention that yes I did delete the edgedb.toml file but that didn't help. Also, in regards to the confused by the duplicate names, I deleted all references to edgedb installation before re-installing (I manually deleted the list of files/folders from edgedb info), so, I reinstalled it twice.

Maybe this bit of info helps to identify the source of the bug.

well1791 avatar Aug 17 '23 14:08 well1791

I also get this issue with edgedb project init and edgedb cli upgrade. With RUST_LOG=TRACE I get

[2023-10-16T20:55:37Z INFO  edgedb::portable::repository] Fetching JSON at https://packages.edgedb.com/archive/.jsonindexes/x86_64-apple-darwin.json
[2023-10-16T20:55:37Z DEBUG reqwest::connect] starting new connection: https://packages.edgedb.com/
edgedb error: failed to fetch JSON at URL: https://packages.edgedb.com/archive/.jsonindexes/x86_64-apple-darwin.json: error sending request for url (https://packages.edgedb.com/archive/.jsonindexes/x86_64-apple-darwin.json): error trying to connect: tcp connect error: Operation not permitted (os error 1): error trying to connect: tcp connect error: Operation not permitted (os error 1): tcp connect error: Operation not permitted (os error 1): Operation not permitted (os error 1)

My EdgeDB CLI version is EdgeDB CLI 3.5.0+d39be05 and I'm on macOS 13.6 x86_64.

I'm typically on a corporate network behind an SSL proxy so that was my initial thought but I get the same error on my home network. (Still on my corporate laptop though so that may have something to do with it.) I have no trouble curling the URL mentioned.

mfenn avatar Oct 16 '23 20:10 mfenn

It's been long since I had this issue, somehow it solved on its own after a week or two (since I opened this issue). I believe it could be something related to some weird cache that eventually wast just dismissed due to the long period.

well1791 avatar Oct 17 '23 01:10 well1791

Same error. Restarting my computer fixed it. Probably is some weird cache issue

youngkidwarrior avatar Oct 26 '23 21:10 youngkidwarrior

Getting this on Mac Sonoma 14.4.1, tried VPN, tried different projects, nothing works but restarting my computer, then it works for a bit then returns to the previous state at some point, can't make sense of this

KatFishSnake avatar May 11 '24 18:05 KatFishSnake

This may be related to device management software (specifically JAMF).

It may be useful to provide traces from the macOS Console application, filtering on edgedb and Errors and Faults. If you are running MDM software on a corporate laptop, providing logs (ie: JAMF) may also be useful.

mmastrac avatar Jun 28 '24 20:06 mmastrac

I'm suddenly experiencing the same problem. Until today, everything worked as expected.

What I've tried so far without any luck:

  • Restarted the computer
  • Reinstalled edgedb-cli using brew
  • Installed edgedb using the installation script from the site (after having removed the brew version)
  • Added edgedb to 'Full disk access'

I am running macOS 14.6.1 on a stand-alone/unmanaged MacStudio.

It seems that something has changed, but looking at the date this issue was created, I don't think it relates to the recent macOS update?

The error when running RUST_LOG=TRACE edgedb project init without a edgedb.toml file:

Checking EdgeDB versions...
[2024-08-22T13:22:21Z TRACE mio::poll] registering event source with poller: token=Token(1), interests=READABLE
[2024-08-22T13:22:21Z INFO  edgedb::portable::repository] Fetching JSON at https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json
[2024-08-22T13:22:21Z DEBUG reqwest::connect] starting new connection: https://packages.edgedb.com/
edgedb error: failed to fetch JSON at URL: https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json
  Caused by: error sending request for url (https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json)
  Caused by: client error (Connect)
  Caused by: tcp connect error: Operation not permitted (os error 1)
  Caused by: Operation not permitted (os error 1)

ewildee avatar Aug 22 '24 13:08 ewildee

Using another MacBook, I've pinpointed the problem to macOS' built-in firewall: When enabled, edgedb project init fails on both. When disabled, it works. Adding iTerm or the edgedb binary to the list of exceptions doesn't work. Can anyone else give it a try or compare their settings with mine? Perhaps there's a related process running that handles connections and should be whitelisted?

Both M1-based systems run macOS 14.6.1, edgedb CLI 5.2.3+4559649, and have their .../Cached/edgedb and .../Application Support/edgedb directories cleared before running the command.

The failing firewall configuration:

  • Firewall: On
  • Block all incoming connections: Off
  • All listed apps: Allow incoming connections
    • Tried iTerm.app and edgedb too
  • Automatically allow built-in ... connections: On
  • Automatically allow downloaded signed ... connections: On
  • Enable stealth mode: Off

ewildee avatar Aug 22 '24 14:08 ewildee

Interesting! I'll try to reproduce this locally.

OK, this doesn't repro on my mac running 14.5. I'll try upgrading.

mmastrac avatar Aug 23 '24 18:08 mmastrac

@ewildee In the meantime, could you try re-signing the edgedb binary:

codesign --force --sign - '/Users/<username>/Library/Application Support/edgedb/bin/edgedb'

In addition, could you check to see if there are any quarantine flags on that binary?

xattr '/Users/<username>/Library/Application Support/edgedb/bin/edgedb'

mmastrac avatar Aug 23 '24 18:08 mmastrac

I ran this on an M3 Pro, upgraded to the latest Sonoma: 14.6.1 (23G93)

Ran both the curl installer, and the brew installer, both worked. Tried removing, cleaning, a few times and eventually started failing as well. Toggling firewall fixes it.

edgedb project init
Found `edgedb.toml` in /Users/matt
Initializing project...
Specify the name of EdgeDB instance to use with this project [default: matt]:
> matt
Checking EdgeDB versions...
edgedb error: failed to fetch JSON at URL: https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json
  Caused by: error sending request for url (https://packages.edgedb.com/archive/.jsonindexes/aarch64-apple-darwin.json)
  Caused by: client error (Connect)
  Caused by: tcp connect error: Operation not permitted (os error 1)
  Caused by: Operation not permitted (os error 1)

mmastrac avatar Aug 23 '24 20:08 mmastrac

@mmastrac Sorry for the delay. Since you've already created a PR, I don't think you need me to try your re-signing suggestion? Thanks for your quick response and excellent software!

ewildee avatar Aug 26 '24 12:08 ewildee

I tested re-signing locally and it unfortunately didn't work. I'm not sure if re-signing with a full codesigning key would help, but that would certainly be an extended process for us to support.

What appears to help is upgrading all of our dependencies en-masse, however this breaks support on some older operating systems. We'll need to evaluate a few options here as we move forward, but your discovery that the firewall is affecting this download was critical and brilliant and you have my thanks for helping narrow that down!

If you keep an eye on that PR and this issue, we'll hopefully have some information at some point in the future, but I don't know if I can promise any timelines due to the complexity of this fix.

mmastrac avatar Aug 26 '24 15:08 mmastrac