dcermak / rpm-spec-language-server

Language Server for RPM spec files
GNU General Public License v2.0
21 stars 3 forks source link

No such file or directory: '/usr/share/doc/rpm/spec.md' #148

Closed FrostyX closed 4 months ago

FrostyX commented 5 months ago

Running the LSP server in container (quay.io/fedora/fedora:39) fails with:

[root@9b325001ba89 rpm_spec_language_server]# /usr/local/bin/rpm_lsp_server 
Traceback (most recent call last):
  File "/usr/local/bin/rpm_lsp_server", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rpm_spec_language_server/main.py", line 46, in main
    server = create_rpm_lang_server()
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rpm_spec_language_server/server.py", line 126, in create_rpm_lang_server
    rpm_spec_server = RpmSpecLanguageServer()
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rpm_spec_language_server/server.py", line 77, in __init__    spec_md_from_rpm_db() or ""
    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rpm_spec_language_server/extract_docs.py", line 160, in spec_md_from_rpm_db
    with open(path) as spec_md_f:
         ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/doc/rpm/spec.md'

Is it possible to put some fallback into the code in case the file doesn't exist? So we don't have a runtime dependency on a documentation file?

Tested with both 0.0.1 version and current upstream commit (1143f882308912962090d3ff9b3c2bf6b3e6ebc0).

mcepl commented 4 months ago

Duplicate of https://github.com/dcermak/rpm-spec-language-server/issues/30.

Just make sure in the container that ~/.cache/rpm/spec.md exists and has the proper content.

FrostyX commented 4 months ago

I think the issue is still valid. As a user, I have no idea that I have to create ~/.cache/rpm/spec.md and what should be inside. Failing with a user-friendly error message would be a good enough fix.

mcepl commented 4 months ago

I think the issue is still valid. As a user, I have no idea that I have to create ~/.cache/rpm/spec.md and what should be inside. Failing with a user-friendly error message would be a good enough fix.

Yes, this is just a hack for those who cannot help themselves (like me, who is on MicroOS, which doesn’t install documentation on the host system). A proper solution would be to install in your container whatever package you need for spec.md fully, including its documentation (rpm in my case).