Repository: Brendonovich/prisma-client-rust (language: rust)

Issue:
prisma-fmt-debian-openssl-1.1.x was not included into executable
When running `prisma-client-rust` I keep receiving the following error which prevents me from using this project.
```bash
> Downloading Prisma engines for Node-API for debian-openssl-1.1.x [========            ] 39%Error: File or directory '/**/node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x' was not included into executable at compilation stage. Please recompile adding it as asset or script.
```
I am running on `Linux 5.13.0-35-generic #40~20.04.1-Ubuntu`.

This error looks the same as prisma/prisma-client-go#449 but they seem to be struggling to debug it due to it being an intermittent issue. I have managed to make a Dockerfile [here](https://gist.github.com/oscartbeaumont/b9ebfe7c57f66a369a89dd60219c05fa) which reproduces this issue using `prisma-client-rust` but I am unable to get the same error when using `prisma-client-go` in a similar setup.


Discussion / hints:
Does the Client set either `PRISMA_QUERY_ENGINE_LIBRARY` or `PRISMA_MIGRATION_ENGINE_BINARY` pointing to a file that contains the appropriate file `prisma-fmt-debian-openssl-1.1.x`? That should skip the download logic in the CLI.
If I use the following commands everything works. Thanks @janpio.
```bash
# Permission issue workaround -> Discussed below
sudo mkdir /snapshot
sudo chown -R $(id -u):$(id -g) /snapshot

# First CLI execution downloads the correct binary and throws the error. Send execution works correctly.
prisma-client-rust generate
export PRISMA_QUERY_ENGINE_LIBRARY=/snapshot/node_modules/prisma/node_modules/@prisma/engines/
prisma-client-rust generate
```

To fix this would it make sense for the `prisma-client-rust` CLI to determine if this file is needed, download it and set the environment variables or should a different version of the Prisma CLI be downloaded which includes the expected file.

It's also worth noting that the Prisma CLI is downloading the binaries to the `/snapshot` directory on my system. Writing files here is both undesired and also introduces permission issues for most Linux setups. Although this won't be an issue if `prisma-client-rust` is in charge of downloading the file.
That is generally a thing the Rust Client (which is modelled after how the Go Client works) should be doing. Seems for some reason it does not do that for you, leading to the suboptimal Prisma CLI included code for downloading to be triggered. 

We also want to fix that `/snapshot` bug internally in the packaged CLI, but that is not a priority right now.

Fix patch:
diff --git a/cli/src/binaries/mod.rs b/cli/src/binaries/mod.rs
index b9d4f1af..9f3d246c 100644
--- a/cli/src/binaries/mod.rs
+++ b/cli/src/binaries/mod.rs
@@ -61,8 +61,6 @@ pub fn fetch_native(to_dir: &PathBuf) -> Result<(), String> {
 
     download_cli(to_dir)?;
 
-    println!("Downloading binaries...");
-
     for e in &ENGINES {
         download_engine(&e.name, &to_dir)?;
     }
@@ -88,7 +86,6 @@ pub fn download_cli(to_dir: &PathBuf) -> Result<(), String> {
     match metadata(&to) {
         Err(_) => (),
         Ok(_) => {
-            println!("{} is cached", to.to_string());
             return Ok(());
         }
     };
@@ -119,16 +116,14 @@ fn download_engine(engine_name: &str, to_dir: &PathBuf) -> Result<(), String> {
         ),
     );
 
-    println!("Downloading {} to {}", url, to);
-
     match metadata(&to) {
         Err(_) => {}
         Ok(_) => {
-            println!("{} is cached", to.to_string());
             return Ok(());
         }
     };
 
+    println!("Downloading {} to {}", url, to);
     download(url.clone(), to.clone()).expect(&format!("could not download {} to {}", url, to));
 
     Ok(())
diff --git a/cli/src/prisma_cli.rs b/cli/src/prisma_cli.rs
index 382d3822..b6715bae 100644
--- a/cli/src/prisma_cli.rs
+++ b/cli/src/prisma_cli.rs
@@ -1,4 +1,4 @@
-use crate::binaries::{self, ENGINES, platform};
+use crate::binaries::{self, platform, ENGINES};
 use std::env;
 use std::process::Command;
 
@@ -17,6 +17,7 @@ pub fn main(args: &Vec<String>) {
 
     cmd.envs(env::vars());
     cmd.env("PRISMA_HIDE_UPDATE_MESSAGE", "true");
+    cmd.env("PRISMA_CLI_QUERY_ENGINE_TYPE", "binary");
 
     for e in ENGINES {
         match env::var(e.env) {


Test patch: