compojure
compojure copied to clipboard
"lein ring server" in WSL - Can i configure the browser behavior?
Windows 10, Windows Subsystem for Linux.
I run "lein ring server" and it fails because i don't have an DISPLAY set up to launch a default browser. Is there a way to make lein aware of WSL and have it use OS Browser somehow?
Or a way to change the behavior of it so it won't throw so many errors on startup? (not open browser by default)
2019-10-30 17:10:22.178:INFO::main: Logging initialized @1920ms
2019-10-30 17:10:25.847:INFO:oejs.Server:main: jetty-9.2.21.v20170120
2019-10-30 17:10:25.897:INFO:oejs.ServerConnector:main: Started ServerConnector@32e736a7{HTTP/1.1}{0.0.0.0:3000}
2019-10-30 17:10:25.899:INFO:oejs.Server:main: Started @5641ms
Started server on port 3000
Exception in thread "main" Syntax error compiling at (/tmp/form-init8347044386782256737.clj:1:73).
at clojure.lang.Compiler.load(Compiler.java:7647)
at clojure.lang.Compiler.loadFile(Compiler.java:7573)
at clojure.main$load_script.invokeStatic(main.clj:452)
at clojure.main$init_opt.invokeStatic(main.clj:454)
at clojure.main$init_opt.invoke(main.clj:454)
at clojure.main$initialize.invokeStatic(main.clj:485)
at clojure.main$null_opt.invokeStatic(main.clj:519)
at clojure.main$null_opt.invoke(main.clj:516)
at clojure.main$main.invokeStatic(main.clj:598)
at clojure.main$main.doInvoke(main.clj:561)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:37)
Caused by: java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
at java.desktop/java.awt.Window.
obviously i can open a browser and go to localhost:3000 :) but figured i'd ask if there was a way to clean this up (i'm a total newb with this stuff)
There are three things you can do, either of which could solve the issue.
- Add
:jvm-opts ["-Djava.awt.headless=true"]
to your project.clj. This prevents the JVM from searching for an X server. - Install an X server on the Windows end and configure WSL to use it.
- Start your application with
lein ring server-headless
. This way, ring-server won't try to open a browser window.
IMO, number 3 might be your best bet: number 2 is a bit of an overkill and number 1 is something I've run into myself while attempting to run an app inside a Docker container.
none of them worked and i tried doing with this project (https://gitlab.com/programacaofuncional/financeiro) can someone else pls try it for me bc i can be my machine