NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.08k forks source link

libGL.so missing in the mesa-drivers package #40001

Closed tiramiseb closed 6 years ago

tiramiseb commented 6 years ago

Issue description

After upgrading from 18.03 to unstable, curabydagoma (whose package I maintain) does not work anymore, with error "Unable to load OpenGL library". I have easily narrowed it down to the pyopengl package.

But I don't know what I can do to fix this error...

Steps to reproduce

$ nix-shell -p pythonPackages.pyopengl --run 'python -c "from OpenGL.GLU import *"'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/GLU/__init__.py", line 2, in <module>
    from OpenGL import platform
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/__init__.py", line 35, in <module>
    _load()
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/__init__.py", line 32, in _load
    plugin.install(globals())
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 92, in install
    namespace[ name ] = getattr(self,name,None)
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in __get__
    value = self.fget( obj )
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/glx.py", line 96, in GetCurrentContext
    return self.GL.glXGetCurrentContext
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/baseplatform.py", line 14, in __get__
    value = self.fget( obj )
  File "/nix/store/rvpx3bywp7frx906whk288c8m7g41pdv-python2.7-pyopengl-3.1.0/lib/python2.7/site-packages/OpenGL/platform/glx.py", line 20, in GL
    raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'libGL.so: cannot open shared object file: No such file or directory', 'libGL.so', 'libGL.so')

Technical details

lheckemann commented 6 years ago

This works for me. Do you have /run/opengl-driver/lib in your LD_LIBRARY_PATH?

tiramiseb commented 6 years ago

Yes:

$ echo $LD_LIBRARY_PATH | grep /run/opengl-driver/lib
/nix/store/b68fx6ng2nvrdffkgpk71c7a8412lapr-sane-config/lib/sane:/run/opengl-driver/lib

... but no libGL.so in this directory...

So, with a little more digging, when looking at the mesa-driver package contents (because /run/opengl-driver/lib is a symlink to /nix/store/[...]-mesa-drivers[...]/lib ), it looks like there is something wrong with what I have in this package on unstable:

ls -1 /nix/store/*mesa-drivers*/lib          
/nix/store/2z8y0ww6qrjrg7wlnq8lwlsqd8k18sk7-mesa-drivers+txc-17.3.6/lib:
bellagio
d3d
dri
libEGL.la
libEGL.so
libEGL.so.1
libEGL.so.1.0.0
libgbm.la
libgbm.so
libgbm.so.1
libgbm.so.1.0.0
libglapi.la
libglapi.so
libglapi.so.0
libglapi.so.0.0.0
libGLESv1_CM.la
libGLESv1_CM.so
libGLESv1_CM.so.1
libGLESv1_CM.so.1.1.0
libGLESv2.la
libGLESv2.so
libGLESv2.so.2
libGLESv2.so.2.0.0
libGL.la
libGL.so
libGL.so.1
libGL.so.1.2.0
libtxc_dxtn.la
libtxc_dxtn.so
libtxc_dxtn.so.0
libtxc_dxtn.so.0.0.0
libvulkan_intel.la
libvulkan_intel.so
libvulkan_radeon.la
libvulkan_radeon.so
libwayland-egl.la
libwayland-egl.so
libwayland-egl.so.1
libwayland-egl.so.1.0.0
libxatracker.la
libxatracker.so
libxatracker.so.2
libxatracker.so.2.3.0
libXvMCgallium.so
libXvMCgallium.so.1
libXvMCgallium.so.1.0.0
libXvMCnouveau.so
libXvMCnouveau.so.1
libXvMCnouveau.so.1.0
libXvMCnouveau.so.1.0.0
libXvMCr600.so
libXvMCr600.so.1
libXvMCr600.so.1.0
libXvMCr600.so.1.0.0
pkgconfig
vdpau

/nix/store/zlwfk9riq72lj6d2r57vacvf9adks71r-mesa-drivers+txc-17.3.8/lib:
bellagio
d3d
dri
libEGL_mesa.la
libEGL_mesa.so
libEGL_mesa.so.0
libEGL_mesa.so.0.0.0
libGLX_mesa.la
libGLX_mesa.so
libGLX_mesa.so.0
libGLX_mesa.so.0.0.0
libtxc_dxtn.la
libtxc_dxtn.so
libtxc_dxtn.so.0
libtxc_dxtn.so.0.0.0
libvulkan_intel.la
libvulkan_intel.so
libvulkan_radeon.la
libvulkan_radeon.so
libxatracker.la
libxatracker.so
libxatracker.so.2
libxatracker.so.2.3.0
libXvMCgallium.so
libXvMCgallium.so.1
libXvMCgallium.so.1.0.0
libXvMCnouveau.so
libXvMCnouveau.so.1
libXvMCnouveau.so.1.0
libXvMCnouveau.so.1.0.0
libXvMCr600.so
libXvMCr600.so.1
libXvMCr600.so.1.0
libXvMCr600.so.1.0.0
pkgconfig
vdpau
tiramiseb commented 6 years ago

I see there have been recent changes in https://github.com/NixOS/nixpkgs/commits/master/nixos/modules/hardware/opengl.nix and also in the mesa drivers package. Maybe it is related ?

My 3D hardware is the common Intel laptop chip, no nvidia, no radeon - maybe this information is important here...

tiramiseb commented 6 years ago

By the way, libGL.so is missing in all new occurrences of /nix/store/*mesa-noglu*/lib (version 17.3.8, from nixos-unstable), whereas it is present in all occurrences of version 17.3.6, from nixos-18.03.

knedlsepp commented 6 years ago

This seems to work on (at least) darwin: https://github.com/knedlsepp/nixpkgs/tree/fix-pyopengl

knedlsepp commented 6 years ago

I'm unsure what's the rationale behind not handling libGL.so the same way it is done with libGLU.so: https://github.com/NixOS/nixpkgs/blob/67ef59fd26c78fc34811c846f770ee855b2f0d0f/pkgs/top-level/python-packages.nix#L11572-L11573 but if we do, as mentioned above, it seems to work for me.

gebner commented 6 years ago

That /run/opengl-driver/lib no longer contains libGL is an intentional change introduced by #37369. Directly link to the libraries in the libGL and libGLU packages instead.

tiramiseb commented 6 years ago

Okay so it is indeed a change in mesa-drivers. It may impact other packages too... I think I was having a similar problem with other packages, but I'm not sure anymore and I prefer taking care of one thing at a time. Once I have the pyopengl stuff working, I'll take a look at the other problems I had...

Now that I see how it is done for pyopengl, I may make a PR to do the same on another package, if needed. Thanks

cx405 commented 6 years ago

@Mic92 @tiramiseb Packages Minetest and Openarena are still affected by issue.

danbst commented 4 years ago

I haven't found a better way than to reintroduce libGL.so back to /run/opengl-driver/lib:

   hardware.opengl = {
     enable = true;
     extraPackages = with pkgs; [
       ...
       libGL
     ];
     setLdLibraryPath = true;
   };
codymikol commented 4 weeks ago

I haven't found a better way than to reintroduce libGL.so back to /run/opengl-driver/lib:

   hardware.opengl = {
     enable = true;
     extraPackages = with pkgs; [
       ...
       libGL
     ];
     setLdLibraryPath = true;
   };

Thank you for this, I've spent 3 days trying to make libGL.so availalbe and this finally did it :pray: