Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL: unable to open display #23

Open
guibou opened this issue Nov 7, 2017 · 11 comments
Open

OpenGL: unable to open display #23

guibou opened this issue Nov 7, 2017 · 11 comments

Comments

@guibou
Copy link

guibou commented Nov 7, 2017

nix-bundle blender /bin/blender

Will fail with:

$ ./blender          
Unable to open a display
../run: line 1: 27203 Aborted                 ./nix/store/c1x6kjxjvbjzqzjcv38ni5mb9zpb7khx-nix-user-chroot-2b144e/bin/nix-user-chroot ./nix /nix/store/1fqm7lqkjdkcfdj1fz9b7n0xizznqy82-blender-2.79/bin/blender $@

On nixos 17.09.1997.1a8a95e879 (Hummingbird) using the packaged nix-bundle.

@matthewbauer
Copy link
Owner

matthewbauer commented Nov 8, 2017

So my bet is that some env var is not available in the container. We set a few here:

https://github.com/matthewbauer/nix-bundle/blob/master/AppRun.c#L231-L242

Something to try would be to run strace and see if it's trying to access a file that's not in the mount namespace.

@matthewbauer
Copy link
Owner

Okay my latest commit should fix this. To test it:

git clone https://github.com/matthewbauer/nix-bundle
cd nix-bundle
./nix-bundle.sh blender /bin/blender

@guibou
Copy link
Author

guibou commented Nov 8, 2017

It does not unfortunately. Tested on nixos and arch linux (the nix-bundle call was done on nixos and the file was transfered to arch by ssh).

I tried with something "simpler", glxinfo and it is the same:

[guillaume@skolem:/tmp/nix-bundle]$ git describe --tags
v0.2.0-4-gaa4d9f9

[guillaume@skolem:/tmp/nix-bundle]$ ./nix-bundle.sh glxinfo /bin/glxinfo
Nix bundle created at glxinfo.

[guillaume@skolem:/tmp/nix-bundle]$ ./glxinfo
No protocol specified
Error: unable to open display :0

@matthewbauer
Copy link
Owner

matthewbauer commented Nov 9, 2017

Ok so adding the /tmp dir in the latest commit gets us a little farther:

name of display: :0
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  48
  Current serial number in output stream:  47

I wonder why it can't find the driver?

@guibou
Copy link
Author

guibou commented Nov 9, 2017

Ok, stuff starts to be really interesting.

The status of OpenGL on nix/nixos is a bit broken. OpenGL is a system library (and impure by definition), and the mesa package contains a hack to find the libGL in /run/opengl-drivers and nixos runs a boot-time service which sets symbolic links in this directory. More details here:

I don't know about the internal of nix-bundle, but to work with OpenGL, it needs, at least, to give an access to the host system /run/opengl-drivers, so it will work on nixos or any system where nix is installed and the user created the symbolic link. But this is a wrong solution because it means that nix-bundle will only work for OpenGL application on system where nix is already installed, which defeat the purpose of nix-bundle.

A robust solution will be to locate the system libGL (usually in /usr/lib/libGL.so, but not always) and use it, and all of its dependencies.

@Radvendii
Copy link

Is there any progress on this? Or a workaround? Is it just not possible to package graphical apps with nix-bundle?

I am trying to package a game I'm making using nix-bundle, and I'm getting the error "Couldn't find matching GLX visual", which I'm assuming is the same issue described here.

I was able to get it working by wrapping the package in a call to nixGL before wrapping it in nix-bundle, but as mentioned in the issue above, this seems incredibly non-portable.

@Radvendii
Copy link

I was actually able to solve this issue for AppImage by updating the AppRun.c file to the latest from AppImageKit (https://github.com/AppImage/AppImageKit/blob/master/src/AppRun.c). I have the same issue with a non-appimage bundle, and I don't see AppRun.c referenced anywhere from that code, so I'm guessing the two were unrelated?

@arximboldi
Copy link

@Radvendii when I do that I get Error executing '<program>': no such file or directory where <program> is the name of the binary of the app I am packaging. Did you do anything else to get it working?

@Radvendii
Copy link

@arximboldi I don't remember the minimal changes to get this part of things working, but I actually wound up doing a bunch of work on the appimage infrastructure. You can see my PR here #76, and try it out by referring to my fork of nix-bundle https://github.com/radvendii/nix-bundle

@arximboldi
Copy link

Thank you so much @Radvendii!! I'm gonna definitelly take a look!

@arximboldi
Copy link

@Radvendii, I just tried that PR and I am having the same issue. I'm writing with more details in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants