38

Is it possible to have xvfb-run on OS X?

I develop a PHP application which uses xvfb-run. Before I worked on Ubuntu and it was OK. Now I've moved onto Mac and the application does not work.

Or maybe any cross-platform alternative is available to use it on both Linux/OS X?

Axarsu
  • 447
  • 1
  • 5
  • 10
  • What is your application using xvfb-run for? –  Aug 22 '14 at 17:54
  • i use it and whtmltoimage to render HTML code indo PNG image. xvfb-run is needed to be able to run the rendering in headless mode. – Axarsu Aug 22 '14 at 18:08
  • 6
    Xvfb is included with OSX 10.9.x (or XQuartz, need to check) - not sure about 10.8, because I don't have it any more. `$ type Xvfb; Xvfb is /opt/X11/bin/Xvfb`. You can simply run it like this: `Xvfb :5 -ac -screen 0 1024x768x8 -extension GLX` - and then let your X11-application connect to this screen by setting `DISPLAY=:5.0`. This link might be helpful: http://afitnerd.com/2011/09/06/headless-browser-testing-on-mac/ – Alexander Janssen Sep 22 '14 at 06:37
  • 1
    @AlexanderJanssen why do you use `DISPLAY=:5.0` and not `DISPLAY=:5`? – user5359531 Jun 08 '18 at 21:34

1 Answers1

17

X11 is no longer included with OS X:

https://support.apple.com/en-us/HT201341

X11 server and client libraries for OS X are available from the XQuartz project:

http://xquartz.macosforge.org/

I'm not sure if it includes all the other X goodies like Xvfb. In that case you could compile it yourself; with these options:

--disable-xquartz --enable-xvfb --enable-xnest --enable-kdrive

More info here:

https://www.xquartz.org/Developer-Info.html

IMO: It seems like you would be better of by using wkhtmltoimage straight on the mac osx, removing the need for X:

http://minimul.com/install-osx-wkhtmltoimage-binaries.html

Clay
  • 4,700
  • 3
  • 33
  • 49
acidjunk
  • 1,751
  • 18
  • 24
  • 3
    This gets you the `xvfb` command, but it doesn't get you to `xvfb-run` which is what the PHP library wants. – russellmania Oct 09 '17 at 22:24
  • 2
    I don't have a compiled version available: the run is just a bash script, seems that this would suffice -> https://gist.github.com/tyleramos/3744901 – acidjunk Oct 10 '17 at 10:25
  • That does not work. It calls a lot of commands that do not exist on macOS/OS X – user5359531 Jun 08 '18 at 21:32
  • 1
    Define "that" (I outlined 2 possible solutions) – acidjunk Jun 10 '18 at 10:14
  • @acidjunk the script you linked is just completely incompatible with mac, not because of missing commands, but also because some of them work in a different way than in Linux. – castarco Mar 29 '21 at 12:24
  • for the missing xvfb-run script: The script is indeed Linux: but it's a simple bash script so it should be possible to rewrite that for your needs; considering that you have a working xfvb binary on Mac. Anno 2021; 6 years after I think an Ubuntu docker / Vagrant will make it a lot easier. – acidjunk Apr 21 '21 at 20:02