https://linen.dev logo
Shuttle deploy fails to provision static folder
# help
a
Pastebin: https://pastebin.com/kjCbw1ma Works totally fine in localrun, not sure why it's screwing up on deploy. I'm using compiled assets from React but it should work as it works completely fine on my next.js rust example as it's basically been implemented the exact same way
k
What does your shuttle main function look like?
a
Copy code
#[shuttle_service::main]
async fn main(
    #[shuttle_secrets::Secrets] secrets: SecretStore,
    #[shuttle_static_folder::StaticFolder] static_folder: PathBuf
) -> ShuttleAxum {

    // We use Secrets.toml to set the BEARER key, just like in a .env file and call it here
    let secret = secrets.get("BEARER").unwrap_or("Bear".to_string());

    // set up router with Secrets & use syncwrapper to make the web service work
    let router = router(secret, static_folder);
    let sync_wrapper = SyncWrapper::new(router);

    Ok(sync_wrapper)
}
The router fn just to make sure it's not that causing the problem
Copy code
fn router(secret: String, static_folder: PathBuf) -> Router {
    // initialise the Users k/v store and allow the static files to be served
    let users = Users::default();

    // make an admin route for kicking users
    let admin = Router::new()
    .route("/disconnect/:user_id", get(disconnect_user))
    .layer(RequireAuthorizationLayer::bearer(&secret));

    let static_assets = SpaRouter::new("/", static_folder) .index_file("index.html").handle_error(handle_error);

    // return a new router and nest the admin route into the websocket route
     Router::new()
        .route("/ws", get(ws_handler))
        .nest("/admin", admin)
        .layer(Extension(users))
        .merge(static_assets)
}
k
Hmmm, it looks correct to me 🤔
a
Yeah. I have no idea what's going wrong
k
Still not working Josh? We had some internal issues, it may have caused some odd errors like this.
a
Still fails to provision on my React app, I'm going to try re-deploying the nextjs-rust example just to see if it errors out on that
Fails on the next.js rust example as well
k
Hmm, with the same error?
a
Yeah it just says that it failed to provision
shuttle_static_folder::StaticFolder
k
Hmm, I tested this now and it deploys:
a
Just going to try destroying the project, creating one with a new name and re-deploying - it deployed fine before I added the lib so not sure what's exactly happened
Still broken
k
Does the example work for you?
a
Having a look now
Looks like the deploy was successful
k
Hmm, the plot thickens. If you have this in a public repo, or can create a minimal reproducible example I can clone, I can take a closer look.
a
I haven't update the get started docs but if you haven't already you'll want typescript installed on npm otherwise the react assets won't compile (written in typescript). Kind of tempted to keep the compiled assets on the repo but ./shrug
k
Thanks! I may not have time today, but I'll take a look as soon as I do.
Feel free to remind me if I forget 😅
a
No problem 😁
n
I was having the same issue, it's caused by static being listed in your .gitignore
a
Ah - that's something I didn't consider, thank you! I'll make sure to make people aware of that if it pops up again
k
While it's not solved, we found a pretty good workaround for this issue. You can use a
.ignore
file to override the gitignore, so it's still ignored by git but not by the shuttle builder. Example:
6 Views