https://linen.dev logo
Setting up diesel with Shuttle.rs, Error: Thread p...
# help
g
This is more of a diesel issue than an Shuttle I'm running into a problem with the diesel setup thread 'main' panicked at 'called Option::unwrap() on a None value', /Users/shariftarver/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_cli-2.0.1/src/database.rs:359:20 I follow that URL and it takes me to this line: let database = base.path_segments().unwrap().last().unwrap().to_owned(); this is suggesting that my database url is empty but its not in my .env file, i have my variable set to this : DATABASE_URL=shear-db-1.asdfdfdsxfed.us-east-1.rds.amazonaws.com this is the function I'm calling to setup the db with the
Copy code
diesel setup
cmd
Copy code
pub fn establish_connection() -> Pool<ConnectionManager<PgConnection>> {
    let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
    let manager = ConnectionManager::<PgConnection>::new(database_url);
    Pool::new(manager).expect("Failed to create pool.")
}
a
It looks like you need to set a database name of some kind after your base URL (the average postgres URL will look something like this):
postgres://postgres:password@localhost:5432/DBnamehere
in this case, it looks like they want you to format your database url in the form of a postgres connection string
if dotenvy (or your method of choice for accessing .env) doesn't work, i'd try using
shuttle-secrets
and feeding that into the connection manager instead of using std::env::var - docs are here if you need them https://docs.shuttle.rs/resources/shuttle-secrets
g
Thank you! that is extremely helpful @agreeable-painting-48846
a
no problem, happy to help 🙂
wait is this about diesel or shuttle in general?
c
my bad, wrong thread
sorry!
a
It's ok no worries 😁
3 Views