NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.2k stars 13.48k forks source link

Missing Oracle instant Client libraries #310876

Closed ElrohirGT closed 2 weeks ago

ElrohirGT commented 3 months ago

Describe the bug

When I install oracle instant client I expected the /lib directory to contain some libraries, instead it's empty as shown in the screenshot section.

This makes it so that when I try to use the oracle driver for rust it fails with:

Error: DpiError(DbError { code: 0, offset: 0, message: "DPI-1047: Cannot locate a 64-bit Oracle Client library: \"libclntsh.so: cannot open shared object file: No such file or directory\". See https://oracle.github.io/odpi/doc/installation.html#linux for help", fn_name: "dpiContext_createWithParams", action: "load library" })

Steps To Reproduce

Steps to reproduce the behavior:

  1. Copy the following flake:

    {
    inputs = {
    naersk.url = "github:nix-community/naersk/master";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    utils.url = "github:numtide/flake-utils";
    };
    
    outputs = {
    self,
    nixpkgs,
    utils,
    naersk,
    }:
    utils.lib.eachDefaultSystem (
      system: let
        pkgs = import nixpkgs {
          inherit system;
          config = {allowUnfree = true;};
        };
        naersk-lib = pkgs.callPackage naersk {};
      in {
        defaultPackage = naersk-lib.buildPackage ./db_innit;
        devShell = with pkgs;
          mkShell {
            buildInputs = [
              cargo
              rustc
              rustfmt
              pre-commit
              rustPackages.clippy
            ];
            packages = [
              oracle-instantclient
            ];
            RUST_SRC_PATH = rustPlatform.rustLibSrc;
            # ORACLE_HOME = pkgs.oci-cli;
            # ORACLE_HOME = pkgs.oracle-instantclient;
            LD_LIBRARY_PATH = "${pkgs.oracle-instantclient}/lib";
          };
      }
    );
    }
  2. Create an example rust project and add the oracle crate.
  3. Try to connect to a sample DB with:
    
    use oracle::Connection;

fn main() -> Result<(), Box> { println!("Conectand a la DB..."); let conn = Connection::connect( "admin", "12345678", "//dbHost:dbPort/dbService", )?; println!("Conexión obtenida!"); }


### Expected behavior
EDIT: added link in normally.

I expected the oracle instant client to have all libraries it offers when installed [_normally_](https://odpi-c.readthedocs.io/en/latest/user_guide/installation.html).

### Screenshots
![image](https://github.com/NixOS/nixpkgs/assets/45268815/27566670-e955-4524-8970-72ecd3a97aa4)

### Additional context
Add any other context about the problem here.

### Notify maintainers
@dylanmtaylor 
<!--
Please @ people who are in the `meta.maintainers` list of the offending package or module.
If in doubt, check `git blame` for whoever last touched something.
-->

### Metadata
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.

```console
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.87, NixOS, 23.11 (Tapir), 23.11.20240421.a5e4bbc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

ALEZ-DEV commented 1 month ago

the libraries seems to be in the lib version of the package : image

I don't know why these two packages are separate, I think there would be a solution to link the two ? like adding the LD_LIBRARY_PATH to the <id>-oracle-instantclient-21.10.0.0.0-lib ?

aca commented 2 weeks ago
default = pkgs.mkShell {
  shellHook = ''
    export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.oracle-instantclient]};
  '';
};

This works for me.

ElrohirGT commented 2 weeks ago

Thank you for your answers! Unfortunetly I no longer have access to any linux machine to tests the changes...

image

But I honestly think that's the solution. In the end the flake would look like this:

{
  inputs = {
    naersk.url = "github:nix-community/naersk/master";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    utils.url = "github:numtide/flake-utils";
  };

  outputs = {
    self,
    nixpkgs,
    utils,
    naersk,
  }:
    utils.lib.eachDefaultSystem (
      system: let
        pkgs = import nixpkgs {
          inherit system;
          config = {allowUnfree = true;};
        };
        naersk-lib = pkgs.callPackage naersk {};
      in {
        defaultPackage = naersk-lib.buildPackage ./db_innit;
        devShell = with pkgs;
          mkShell {
            buildInputs = [
              cargo
              rustc
              rustfmt
              pre-commit
              rustPackages.clippy
            ];
            packages = [
              oracle-instantclient
            ];
            RUST_SRC_PATH = rustPlatform.rustLibSrc;
            # ORACLE_HOME = pkgs.oci-cli;
            # ORACLE_HOME = pkgs.oracle-instantclient;
            LD_LIBRARY_PATH = lib.makeLibraryPath [oracle-instantclient];
          };
      }
    );
}

I didn't know the packages could have a library path where all this stuff would be located! Nix sure has a lot of quirks. Where did you learn about the function makeLibraryPath @aca ?

aca commented 2 weeks ago

I found it from other pkg definitions. Just tried everything I found. I wish I can learn in better way.