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

Getting Started install instructions lead to TimeoutError on WSL2 #4698

Open
LanHikari22 opened this issue Sep 19, 2024 · 3 comments
Open

Getting Started install instructions lead to TimeoutError on WSL2 #4698

LanHikari22 opened this issue Sep 19, 2024 · 3 comments

Comments

@LanHikari22
Copy link

LanHikari22 commented Sep 19, 2024

Following the instructions in https://github.com/antlr/antlr4/blob/4.13.2/doc/getting-started.md,

  1. I first created a miniconda environment for antlr and then proceeded with installing antlr4-tools:
conda create --prefix /home/lan/miniconda3/envs/antlr python=3.11
conda activate /home/lan/miniconda3/envs/antlr
python3 -m pip install antlr4-tools
  1. I then attempted to install the java app with
antlr4

and that produced the following error log:

Traceback (most recent call last):
  File "/home/lan/miniconda3/envs/antlr/bin/antlr4", line 8, in <module>
    sys.exit(tool())
             ^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/site-packages/antlr4_tool_runner.py", line 141, in tool
    run_cli('org.antlr.v4.Tool')
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/site-packages/antlr4_tool_runner.py", line 132, in run_cli
    args, version = process_args()
                    ^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/site-packages/antlr4_tool_runner.py", line 126, in process_args
    args.version or os.environ.get("ANTLR4_TOOLS_ANTLR_VERSION") or latest_version()
                                                                    ^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/site-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 "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/urllib/request.py", line 1352, in do_open
    r = h.getresponse()
        ^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/http/client.py", line 1395, in getresponse
    response.begin()
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/http/client.py", line 325, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/http/client.py", line 286, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/socket.py", line 706, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/ssl.py", line 1314, in recv_into
    return self.read(nbytes, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lan/miniconda3/envs/antlr/lib/python3.11/ssl.py", line 1166, in read
    return self._sslobj.read(len, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out

The suspect line is the following:

with urlopen(f"https://search.maven.org/solrsearch/select?q=a:antlr4-master+g:org.antlr", timeout=10) as response:

I am unable to curl nor access this URL in my browser. However, I saw instructions on StackOverflow from user kaby76 (https://stackoverflow.com/q/78059474) to instead run

antlr -v 4.13.1

and that did allow me to acquire the CLI tool:

antlr4 -v 4.13.1
ANTLR Parser Generator  Version 4.13.1
 -o ___              specify output directory where all output is generated
 -lib ___            specify location of grammars, tokens files
 -atn                generate rule augmented transition network diagrams
 -encoding ___       specify grammar file encoding; e.g., euc-jp
 -message-format ___ specify output style for messages in antlr, gnu, vs2005
 -long-messages      show exception details when available for errors and warnings
 -listener           generate parse tree listener (default)
 -no-listener        don't generate parse tree listener
 -visitor            generate parse tree visitor
 -no-visitor         don't generate parse tree visitor (default)
 -package ___        specify a package/namespace for the generated code
 -depend             generate file dependencies
 -D<option>=value    set/override a grammar-level option
 -Werror             treat warnings as errors
 -XdbgST             launch StringTemplate visualizer on generated code
 -XdbgSTWait         wait for STViz to close before continuing
 -Xforce-atn         use the ATN simulator for all predictions
 -Xlog               dump lots of logging info to antlr-timestamp.log
 -Xexact-output-dir  all output goes into -o dir regardless of paths/package

Thanks,
Mohammed

@kaby76
Copy link
Contributor

kaby76 commented Sep 26, 2024

The address is using the ["Official search by the maintainers of Maven Central Repository"](https://search.maven.org/). But, I just clicked on "API Guide", then one of the queries, and the page times out. I think the web service is unreliable. It might be best to use https://central.sonatype.com/?smo=true. It has an API.

@kaby76
Copy link
Contributor

kaby76 commented Sep 26, 2024

504 ERROR
The request could not be satisfied.
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: xGTki_3-jx8ZdW05RJj75iD0N_M_kls3O1UpAEEG1dWcY8qzr_nV2w==

Actually, the sonatype.com website points to the maven.org API. Not much we can do here in so far as using this API. It might be better to just query https://repo1.maven.org/maven2/org/antlr/antlr4/, which appears to be more reliable, and just scan for the latest.

@kaby76
Copy link
Contributor

kaby76 commented Sep 26, 2024

Perhaps something like this? (I am not a Python programmer, but it "works".)

def latest_version():
    page = requests.get("https://repo1.maven.org/maven2/org/antlr/antlr4/")
    tree = html.fromstring(page.content)
    x = tree.xpath('//a/text()')
    if '../' in x: x.remove('../')
    if 'maven-metadata.xml' in x: x.remove('maven-metadata.xml')
    if 'maven-metadata.xml.md5' in x: x.remove('maven-metadata.xml.md5')
    if 'maven-metadata.xml.sha1' in x: x.remove('maven-metadata.xml.sha1')
    if 'maven-metadata.xml.sha256' in x: x.remove('maven-metadata.xml.sha256')
    if 'maven-metadata.xml.sha512' in x: x.remove('maven-metadata.xml.sha512')
    cleaned_data = [item.rstrip('/') for item in x]
    cleaned_data.sort(key=Version)
    last_element = cleaned_data[-1]
    return last_element

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
@kaby76 @LanHikari22 and others