sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 55 forks source link

Installation dependencies on NixOS #155

Open MikiVanousek opened 2 years ago

MikiVanousek commented 2 years ago

The installation instructions list dependencies for different OSes. Did anyone manage to make it work on NixOS? I get the following error:

julia> using GR

julia> histogram(randn(10000))

env: ‘/home/miki/.local/share/julia/artifacts/261454d51a07163528d01f640e8349c372ac05b2/bin/gksqt’: No such file or directory
IngoMeyer441 commented 2 years ago

Hey @MikiVanousek, I tried your example on a fresh NixOS (latest) installation and it works for me. How did you install julia and GR? I fetched Julia from the official home page (binary release) since the Julia package in NixOS is currently broken. I installed GR with the Julia package manager in the REPL (], add GR).

image

MikiVanousek commented 2 years ago

I used the Nixpkgs package julia_17-bin, which works, with the notable exception of Julia packages that ship binaries linked against specific dependency paths that are different on NixOS.

As for just downloading of the binary form the website, I somehow failed at this task. Did you do something besides running the binary in /bin of the downloaded folder? I get:

bash: /home/miki/dow/julia-1.7.3/bin/julia: No such file or directory

even though

/home/miki/dow/julia-1.7.3/bin/julia
MikiVanousek commented 2 years ago

In any case, I don't think there should be much of a difference between the manually downloaded Julia binary and the Nixpkgs one. Would you try it with the NixOS binary? You can obtain it with nix-shell -p julia-stable-bin.

MikiVanousek commented 2 years ago
dow/julia-1.7.3/bin 
❯ nix-shell -p julia-stable-bin

dow/julia-1.7.3/bin via ❄️  impure (shell) 
❯ julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.3 (2022-05-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.7) pkg> add GR
    Updating registry at `~/.local/share/julia/registries/General.toml`
   Resolving package versions...
  No Changes to `~/.local/share/julia/environments/v1.7/Project.toml`
  No Changes to `~/.local/share/julia/environments/v1.7/Manifest.toml`

julia> using GR

julia> histogram(rand(1000))
env: ‘/home/miki/.local/share/julia/artifacts/261454d51a07163528d01f640e8349c372ac05b2/bin/gksqt’: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
IngoMeyer441 commented 2 years ago

with the notable exception of Julia packages that ship binaries linked against specific dependency paths that are different on NixOS.

The problem is caused by a hard-coded ELF interpreter path in the GR binaries. gksqt expects the interpreter to be located at /lib64/ld-linux-x86-64.so.2 which is not the case under NixOS. The official Julia binaries have the same problem, so for a quick and dirty fix I simply created a symlink at /lib64/ld-linux-x86-64.so.2 which was also the reason that gksqt started working.

IngoMeyer441 commented 2 years ago

So the qksqt application either needs to be patched (see https://nixos.wiki/wiki/Packaging/Binaries#The_Dynamic_Loader) or GR should be installed from source. GR.jl can pick up an existing GR installation. However, I am new to NixOS. Is it possible to simple run a make install or must everything be installed with the Nix package manager?

MikiVanousek commented 2 years ago

I am not that well versed in NixOS packaging, but I think the best/most robust way would be to use Nix to package GR, which if you know what you are doing should not be too difficult.

IngoMeyer441 commented 2 years ago

I have no experience with NixOS or Nix at all. For this issue, I set up my first virtual machine with NixOS. It would be great to have a guide for this.