floris-xlx / supabase_rs

Supabase SDK for Rust
MIT License
9 stars 5 forks source link

Add features for rustls instead of openssl #2

Open DoIevenLift opened 3 months ago

DoIevenLift commented 3 months ago

Hi,

Thanks for all your hard work with this. Great project.

I don't even know if this is possible (rust noob) but is there someway to change / add features to the reqwest dependency used? If you are deploying on a provide like AWS lambda using cargo lambda you'll run into these kinds of errors:

image

I know this is probably a niche case and there are ways to get openssl (not recommended by cargo lambda author) to work with rust lambda functions but if you swap openssl to rustls it'll compile no drama. If there is another way would love to be pointed in the right direction.

Again, awesome work!

floris-xlx commented 2 months ago

hello @DoIevenLift,

i appreciate your time for the issue,

i'll add a feature flag either today or tomorrow under openssl,

i'm very familiar with this error mainly on ubuntu builds so expect something soon

floris-xlx commented 2 months ago

i mean rustls not openssl as tag :)

floris-xlx commented 2 months ago

hello @DoIevenLift

I have added a stable rustls feature flag available on the newest version of the crate

https://crates.io/crates/supabase_rs/0.3.1

enable the flag in your cargo.toml as such

supabse_rs = { version = "0.3.1", features = ["rustls"]  }

It will force the request builder of Reqwest to use the rustls backend instead of the defaulted OpenSSL one

if something doesnt work as expected or anything in that nature lmk and ill fix it

I'll leave the issue open for now and close it when you let me know if this resolved your issue

DoIevenLift commented 4 days ago

Hey @floris-xlx ,

My apologies for the delay in getting back to you here.

Have added features and the builder is hitting opensys_ssl still.

error: failed to run custom build command for `openssl-sys v0.9.103`

Caused by:
  process didn't exit successfully: `C:\Users\jacob\Documents\GitHub\rust-server-alive\target\release\build\openssl-sys-17a0de12626f386d\build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_OCB", "OPENSSL_NO_SM4", "OPENSSL_NO_SEED", "OPENSSL_NO_CHACHA", "OPENSSL_NO_CAST", "OPENSSL_NO_IDEA", "OPENSSL_NO_CAMELLIA", "OPENSSL_NO_RC4", "OPENSSL_NO_BF", "OPENSSL_NO_PSK", "OPENSSL_NO_DEPRECATED_3_0", "OPENSSL_NO_SCRYPT", "OPENSSL_NO_SM3", "OPENSSL_NO_RMD160", "OPENSSL_NO_EC2M", "OPENSSL_NO_OCSP", "OPENSSL_NO_CMS", "OPENSSL_NO_COMP", "OPENSSL_NO_SOCK", "OPENSSL_NO_STDIO"))
  cargo:rustc-check-cfg=cfg(openssl)
  cargo:rustc-check-cfg=cfg(libressl)
  cargo:rustc-check-cfg=cfg(boringssl)
  cargo:rustc-check-cfg=cfg(libressl250)
  cargo:rustc-check-cfg=cfg(libressl251)
  cargo:rustc-check-cfg=cfg(libressl252)
  cargo:rustc-check-cfg=cfg(libressl261)
  cargo:rustc-check-cfg=cfg(libressl270)
  cargo:rustc-check-cfg=cfg(libressl271)
  cargo:rustc-check-cfg=cfg(libressl273)
  cargo:rustc-check-cfg=cfg(libressl280)
  cargo:rustc-check-cfg=cfg(libressl281)
  cargo:rustc-check-cfg=cfg(libressl291)
  cargo:rustc-check-cfg=cfg(libressl310)
  cargo:rustc-check-cfg=cfg(libressl321)
  cargo:rustc-check-cfg=cfg(libressl332)
  cargo:rustc-check-cfg=cfg(libressl340)
  cargo:rustc-check-cfg=cfg(libressl350)
  cargo:rustc-check-cfg=cfg(libressl360)
  cargo:rustc-check-cfg=cfg(libressl361)
  cargo:rustc-check-cfg=cfg(libressl370)
  cargo:rustc-check-cfg=cfg(libressl380)
  cargo:rustc-check-cfg=cfg(libressl381)
  cargo:rustc-check-cfg=cfg(libressl382)
  cargo:rustc-check-cfg=cfg(libressl390)
  cargo:rustc-check-cfg=cfg(libressl400)
  cargo:rustc-check-cfg=cfg(ossl101)
  cargo:rustc-check-cfg=cfg(ossl102)
  cargo:rustc-check-cfg=cfg(ossl102f)
  cargo:rustc-check-cfg=cfg(ossl102h)
  cargo:rustc-check-cfg=cfg(ossl110)
  cargo:rustc-check-cfg=cfg(ossl110f)
  cargo:rustc-check-cfg=cfg(ossl110g)
  cargo:rustc-check-cfg=cfg(ossl110h)
  cargo:rustc-check-cfg=cfg(ossl111)
  cargo:rustc-check-cfg=cfg(ossl111b)
  cargo:rustc-check-cfg=cfg(ossl111c)
  cargo:rustc-check-cfg=cfg(ossl111d)
  cargo:rustc-check-cfg=cfg(ossl300)
  cargo:rustc-check-cfg=cfg(ossl310)
  cargo:rustc-check-cfg=cfg(ossl320)
  cargo:rustc-check-cfg=cfg(ossl330)
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at C:\Users\jacob\.cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-sys-0.9.103\build\find_normal.rs:190:5:

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-pc-windows-msvc
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.103

If i remove supabase_rs and do the build - this builds successfully.

I also tried to do supabase_rs = { version blah, default-features = false, features = [ "rustls" ] } & features = [ "rustls-tls" ] no luck in the build phases.

Hope this helps and let me know if there is any further info needed.

Thanks again!

floris-xlx commented 1 day ago

you need to insntsall openSSL on the machine, supabase_rs is the only lib that is probably depednant on it

floris-xlx commented 1 day ago

Try this setup .sh file, i recognize your error as one you usually see on fresh builds that dont have pkg-config installed yet

setup.sh

#!/bin/bash

sudo apt update
sudo apt upgrade -y
sudo apt-get update
sudo apt install -y pkg-config
source $HOME/.cargo/env
sudo apt-get install -y libssl-dev
sudo apt install -y build-essential
sudo apt install -y plocate
sudo updatedb 

openssl_dir=$(dirname $(locate openssl.pc | head -n 1))
if [ -n "$openssl_dir" ]; then
  export PKG_CONFIG_PATH=$openssl_dir
  echo "PKG_CONFIG_PATH set to $PKG_CONFIG_PATH"
else
  echo "openssl.pc not found, PKG_CONFIG_PATH not set."
fi
floris-xlx commented 1 day ago

try running this and then have another go

strykejern commented 1 day ago

I suspect this is because we are pulling in a dependency to openssl when we really don't need to, as we're already using the rustls-tls feature flag for reqwest.

@DoIevenLift Could you try adding the attribute default-features = false to the reqwest dependency to see if that helps you? For me it seems to avoid pulling in Openssl, and might fix your problem.