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

Antlr4 failing to reach out to Maven repository #4703

Open
Cazra opened this issue Sep 27, 2024 · 5 comments
Open

Antlr4 failing to reach out to Maven repository #4703

Cazra opened this issue Sep 27, 2024 · 5 comments

Comments

@Cazra
Copy link

Cazra commented Sep 27, 2024

This morning, I've been having trouble trying to do anything at all with Antlr4. I can't use it to build any of my grammars, and not even antlr4 --help works.

I get the following error output:

Traceback (most recent call last):
  File "/usr/local/bin/antlr4", line 8, in <module>
    sys.exit(tool())
  File "/usr/local/lib/python3.10/dist-packages/antlr4_tool_runner.py", line 141, in tool
    run_cli('org.antlr.v4.Tool')
  File "/usr/local/lib/python3.10/dist-packages/antlr4_tool_runner.py", line 132, in run_cli
    args, version = process_args()
  File "/usr/local/lib/python3.10/dist-packages/antlr4_tool_runner.py", line 126, in process_args
    args.version or os.environ.get("ANTLR4_TOOLS_ANTLR_VERSION") or latest_version()
  File "/usr/local/lib/python3.10/dist-packages/antlr4_tool_runner.py", line 27, in latest_version
    with urlopen(f"https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr", timeout=10) as response:
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/usr/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.10/urllib/request.py", line 1352, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1375, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.10/ssl.py", line 1303, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.10/ssl.py", line 1159, in read
    return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out

It appears to be timing out when it reaches out to its Maven repository.

@kaby76
Copy link
Contributor

kaby76 commented Sep 27, 2024

https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr. I mentioned this here. #4698 (comment). The change, which should be in the antlr4-tools repo, looks instead to https://repo1.maven.org/maven2/org/antlr/antlr4/, avoiding search.maven.org entirely, which is not robust, frequently down--more often than not!

@moogman
Copy link

moogman commented Oct 4, 2024

antlr4 python is unusable again because there's an outage with https://status.maven.org/
This should be a soft failure with antlr4, warning instead of erroring out.
--help and --version should work even if maven is down, and we also should have a --skip-version-check cmdline option.

@moogman
Copy link

moogman commented Oct 4, 2024

Duplicate of antlr/antlr4-tools#18 as this is a bug of antlr4-tools rather than antlr4 itself

@kaby76
Copy link
Contributor

kaby76 commented Oct 4, 2024

Yes, the current workaround is to always use the -v "option." But, you may want to use -v for another reason.

In grammars-v4, we always use the -v "option" because the tool and runtime versions must be kept in sync. So, while a new version of the tool may be released, the runtimes are released in a completely different timetable, sometimes up to a month after the release of the tool.

@moogman
Copy link

moogman commented Oct 4, 2024

Cross referencing to antlr/antlr4-tools#18 (comment)
There's a fix that's not made it to a pip release yet, that errors cleanly when there's a timeout and automatically uses any current JRE as a fallback option.

In the meantime, you can add that manually in your envs:

.env/lib/python3.12/site-packages/antlr4_tool_runner.py:35
-    except (error.URLError, error.HTTPError) as e:
+    except (error.URLError, error.HTTPError, TimeoutError) as e:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants