emacs-lsp / lsp-metals

lsp-mode :heart: metals
https://emacs-lsp.github.io/lsp-metals
GNU General Public License v3.0
58 stars 33 forks source link

Installing/Updating behind proxy #60

Open liar666 opened 3 years ago

liar666 commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

I'm behind a proxy, opening a .scala file leads to lsp + metals trying to install/update, which results in error (buffer *metals::stderr*):

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Error while downloading https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.7/gson-2.8.7.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/ch/epfl/scala/bsp4j/2.0.0-M13/bsp4j-2.0.0-M13.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/ch/epfl/scala/scalafix-interfaces/0.9.27/scalafix-interfaces-0.9.27.jar: Connection timed out (Connection timed out), ignoring it
Error while downloading https://repo1.maven.org/maven2/com/geirsson/metaconfig-core_2.12/0.9.11/metaconfig-core_2.12-0.9.11.jar: Connection timed out (Connection timed out), ignoring it

Process metals stderr finished

Seems that the proxy configuration is not taken into account (I've tried with env vars *_proxy and in emacs config)

To Reproduce Steps to reproduce the behavior(sample project + file which can be used to reproduce the issue with.)

Expected behavior A clear and concise description of what you expected to happen.

All Emacs connexions (included lsp/lsp-* upgrades) should pass through proxy when it is configured

Screenshots If applicable, add screenshots to help explain your problem.

Logs Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication. cf above

EDIT: I've also tried C-u M-x lsp-install-server metals, which seems to have worked (*messages* buffer)

Wrote /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc
LSP :: Finished downloading /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc...
LSP :: Verifying signature /home/gmuller/.emacs.d/.cache/lsp/metals/coursier.asc...
LSP :: Server metals downloaded, auto-starting in 0 buffers.

But without success

EDIT2: I'm discovered metals is installed in /home/user/.emacs.d/.cache/lsp/metals/metals... I've tried to run/update it manually by running the command in a terminal... Seems to ignore the proxy too....

liar666 commented 3 years ago

SOLUTION: Using: $ export _JAVA_OPTIONS=-Djava.net.useSystemProxies=true $ /home/user/.emacs.d/.cache/lsp/metals/metals worked

lsp-metals should add -Djava.net.useSystemProxies=true to any call to metals, or configure JVM's proxy from Emacs proxy configuration

WORK-AROUND: For those with the same problem, running _JAVA_OPTIONS="$_JAVA_OPTIONS -Djava.net.useSystemProxies=true" emacs tmp/lsp/test.scala works

kbrowder commented 1 year ago

Afaict there's no combination of env vars that work to get flags to bootstrap at https://github.com/emacs-lsp/lsp-metals/blob/master/lsp-metals.el#L400, I guess perhaps there should be a lsp-metals-coursier-args to allow adding flags to the bootstrap step, in my case -J-Djavax.next.ssl.trustStore