Libgfortran.so.3 not found but libgfortran.so.5 exists

I’m trying to run rstudio-server on CentOS with the following flake.nix

{
  description = "shell flake for VSCode and RStudio";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/4329d79dbab9f9ae6654c59ac428b8935eb7f7c5";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils, nixgl }:
    flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs {
        inherit system;
      };
    in
      with pkgs; with rPackages;
    let
      rpackage_list = [
      ggplot2
      ]; 
      customRStudioServer = rstudioServerWrapper.override { packages =
        rpackage_list;
      };
    in {
    packages.rstudio-server = customRStudioServer;
    devShell = mkShell {
      nativeBuildInputs = [ bashInteractive ]; # pkgs.bashInteractive
      buildInputs =
      [
        customRStudioServer
      ];
    };
  });
}

When I run rserver --config-file myrserver.conf, The following error occurs.

/nix/store/rsf4q39glsn4rfcvlqjiiw27pl6pwz46-RStudio-1.4.1717/bin/rsession: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory

If I do

ldd /nix/store/rsf4q39glsn4rfcvlqjiiw27pl6pwz46-RStudio-1.4.1717/bin/rsession

There is indeed no libgfortran.so.3. Only libgfrotran.so.5 exists as follows.

libgfortran.so.5 => /nix/store/1ghxrdlh0c5z6kgck5ciwymxphnw8j17-gfortran-9.3.0-lib/lib/libgfortran.so.5 (0x00007feee0f9e000)

How can I fix this? Do I have to add libgfortran.so.3? It seems that gfortran.lib.cc contains only libgfortran.so.5. How can I solve this issue?

I believe this is from an ancient version of gcc (e.g. gcc 6), is the CentOS environment affecting the executable at all?

$[22:28:45] jon@nixos ~/projects/nixpkgs (master)
$ ls $(nix-build -A gfortran6.cc.lib)/lib/libgfor*
/nix/store/1ckg2q86j3hv0m2r6vvmri3jaa34wkwp-gfortran-6.5.0-lib/lib/libgfortran.la
/nix/store/1ckg2q86j3hv0m2r6vvmri3jaa34wkwp-gfortran-6.5.0-lib/lib/libgfortran.so
/nix/store/1ckg2q86j3hv0m2r6vvmri3jaa34wkwp-gfortran-6.5.0-lib/lib/libgfortran.so.3
/nix/store/1ckg2q86j3hv0m2r6vvmri3jaa34wkwp-gfortran-6.5.0-lib/lib/libgfortran.so.3.0.0
1 Like

Yes I’m guessing you’re running RHEL <=6 or the equivalent CentOS version, and you have your Nix library paths being clobbered by the system.

I had this exact issue on RHEL 6 for years.

1 Like