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

Allow binary location to be defined via env variables #395

Closed
Ziothh opened this issue Sep 6, 2023 · 4 comments · Fixed by #405
Closed

Allow binary location to be defined via env variables #395

Ziothh opened this issue Sep 6, 2023 · 4 comments · Fixed by #405

Comments

@Ziothh
Copy link
Contributor

Ziothh commented Sep 6, 2023

Unsupported linux distro

I'm using PCR on NixOS and I get this error when using the CLI (cargo run --bin prisma -- db push):

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/zioth/.cargo/git/checkouts/prisma-client-rust-fa967aa5ad0ec391/c965b89/cli/src/prisma_cli.rs:40:18

Which is caused by this line of code in prisma-client-rust/crates/cli/src/prisma_cli.rs#L40

Prisma does not have precompiled binaries for NixOS so I had to add them with a flake:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        packages = with pkgs; [
          # Snip ... tauri deps

          openssl_3
          glib
          nodejs_20
        ];
      in
      {
        devShell = pkgs.mkShell {
          buildInputs = packages;

          shellHook = let prisma-engines = pkgs.prisma-engines; in ''
              PATH="$PWD/node_modules/.bin:$PATH"
              export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH
          '';
          PRISMA_SCHEMA_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/schema-engine";
          PRISMA_QUERY_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/query-engine";
          PRISMA_QUERY_ENGINE_LIBRARY = "${pkgs.prisma-engines}/lib/libquery_engine.node";
          PRISMA_FMT_BINARY = "${pkgs.prisma-engines}/bin/prisma-fmt";
        };
      });
}

Would you be interested in adding support for setting the binary locations via env variables?

Maybe this is related

Also, idk if this is related, when calling pnpm prisma db push I get this error:
(schema.prisma contains both the PCR and native prisma-ts generators)

Warning Precompiled engine files are not available for nixos.
Prisma schema loaded from schema.prisma
Datasource "db": SQLite database "db.sqlite" at "file:./db.sqlite"

The database is already in sync with the Prisma schema.

Running generate... (Use --skip-generate to skip the generators)
Warning Precompiled engine files are not available for nixos.
Generator "cargo prisma" failed:

    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
warning: the following packages contain code that will be rejected by a future version of Rust: bigint v4.4.3
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
     Running `/home/zioth/projects/apps/chess/target/debug/prisma`
thread 'main' panicked at 'Failed to deserialize DMMF from Prisma engines: Error { path: Path { segments: [Map { key: "generator" }, Map { key: "binary
Targets" }, Seq { index: 0 }] }, original: Error("invalid type: map, expected a string", line: 1, column: 1936) }', /home/zioth/.cargo/git/checkouts/pr
isma-client-rust-fa967aa5ad0ec391/c965b89/sdk/src/runtime.rs:57:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

✔ Generated Prisma Client (5.0.0 | library) to ./node_modules/@prisma/client in 45ms
@Falmarri
Copy link

Falmarri commented Oct 2, 2023

Also trying to run this on alpine seems to not work.

Details: /root/.cache/prisma/binaries/cli/4.8.0/d6e67a83f971b175a593ccc12e15c4a757f93ffe/prisma-query-engine-debian-openssl-1.1.x: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

presumably because it gets its binaries from

Downloading https://binaries.prisma.sh/all_commits/d6e67a83f971b175a593ccc12e15c4a757f93ffe/debian-openssl-1.1.x/migration-engine.gz to /root/.cache/prisma/binaries/cli/4.8.0/d6e67a83f971b175a593ccc12e15c4a757f93ffe/prisma-migration-engine-debian-openssl-1.1.x
Downloading https://binaries.prisma.sh/all_commits/d6e67a83f971b175a593ccc12e15c4a757f93ffe/debian-openssl-1.1.x/introspection-engine.gz to /root/.cache/prisma/binaries/cli/4.8.0/d6e67a83f971b175a593ccc12e15c4a757f93ffe/prisma-introspection-engine-debian-openssl-1.1.x
Downloading https://binaries.prisma.sh/all_commits/d6e67a83f971b175a593ccc12e15c4a757f93ffe/debian-openssl-1.1.x/prisma-fmt.gz to /root/.cache/prisma/binaries/cli/4.8.0/d6e67a83f971b175a593ccc12e15c4a757f93ffe/prisma-prisma-fmt-debian-openssl-1.1.x

@Ziothh
Copy link
Contributor Author

Ziothh commented Oct 21, 2023

@Falmarri I've created a PR that allows you to manually set the location of the prisma engine binaries.

I suspect that could fix your issue.

You can patch the prisma-client-rust-cli crate to my fork untill it's merged.

@donovanglover
Copy link

I also ran into this issue. Thanks for making the PR!

@jr1221
Copy link

jr1221 commented Jul 20, 2024

Hi,
What must be done to allow prisma cli rust to run on alpine?

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

Successfully merging a pull request may close this issue.

4 participants