rcv icon indicating copy to clipboard operation
rcv copied to clipboard

Using CLI mode on a server with no X

Open hanksims opened this issue 1 year ago • 9 comments

I'd love to use rcv on a Linux server in CLI mode. However, I'm unable to. I get this:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY

Can this be right? Can X be removed as a requirement for command-line operations? Barring that, does anyone have a workaround?

hanksims avatar Jan 24 '24 04:01 hanksims

@artoonie thoughts on this? I agree that in theory this restriction seems unnecessary.

tarheel avatar Jan 26 '24 23:01 tarheel

Agreed.

Is this fixed if you export DISPLAY=:0? Sometimes it's as easy as that.

If not, we can look into fixing it correctly (@yezr would love help prioritizing).

artoonie avatar Jan 26 '24 23:01 artoonie

I just tried it. Same error, alas.

My workaround in the meanwhile -- hopefully temporarily? -- is to run an xvfb server on my machine to fake out rcv. It takes up enough memory to make it hurt a little bit.

hanksims avatar Jan 27 '24 00:01 hanksims

@hanksims thanks for the heads up. Do you know how many people this effects? Is this all linux machines (or most?)

yezr avatar Jan 30 '24 14:01 yezr

I believe it would affect all or most Linux machines that are used as servers, in the cloud, where X display servers are uncommon.

hanksims avatar Jan 30 '24 14:01 hanksims

Is there any update on this? I have a use-case that requires running rcv in a docker container without X.

semperstew avatar Jul 21 '24 05:07 semperstew

What is your all's use case? That will help me find a priority. Does @hanksims workaround also work for you?

I will add that the project's current focus is to finish the v2.0 priority list here for upcoming VVSG certification. It will be hard to find space for this above any of that work. If you all can submit a PR with a fix that would make it easier to prioritize. But even then, we have to take resources away from reviewing the current priority list to review any fix.

yezr avatar Jul 22 '24 19:07 yezr

@semperstew and i have a use case in which we're conducting automated polling. we fetch data from S3, push it through an ETL pipeline, and then run it through RCTab in order to get the election results. we've got a poll going in every state, updating a couple of times per day. at the end we upload our results to rcvis.com to visualize them (great tool, that!).

what's weird too, is that using @hanksims workaround i was able to get RCTab running in my local environment (Ubuntu 20.04.6), but not in EC2 (Debian 11). still trying to figure out why that could be.

these are the changes i made to the startup script get it running in Ubuntu:

#!/bin/sh
DIR="${0%/*}"
Xvfb :99 -screen 0 1024x768x16 &   # Start Xvfb in the background
export DISPLAY=:99                 # Set the DISPLAY variable to use Xvfb
"$DIR/java" -Djava.awt.headless=true -p "$DIR/../app" -m network.brightspots.rcv/network.brightspots.rcv.Main  "$@"

nikomaresco avatar Jul 23 '24 22:07 nikomaresco

excellent news. some digging led me to this issue, which suggested to install lib-gtk-3-0. running RCTab with the above modifications to startup gets it working!

you can install the package with apt install libgtk-3-0.

also, note that the startup script i shared above will attempt to start Xvfb every time you run the tabulator, which doesn't do anything detrimental except some angry log messages. but a better script would check if it's currently running first, which a future reader might want to do in production.

nikomaresco avatar Jul 23 '24 22:07 nikomaresco