https://linen.dev logo
No such file or directory (os error 2) actix error
# help
r
In the
Copy code
cargo shuttle run
, I am able to see the html file, but, when I run
Copy code
cargo shuttle deploy
, and visit the url, I am seeing :
Copy code
No such file or directory (os error 2)
, when I view the page path: "/"
a
hey there, thanks for submitting your issue what version of
shuttle-static-folder
are you running?
r
what is that?
Hmm... let me check
I just ran cargo add shuttle-static-folder
a
if you run shuttle-static-folder v0.11.0 it should work
r
I use actix
a
yeah, the
shuttle-static-folder
crate allows you to run static folders on shuttle
r
what must be the name of the folder
I mean what must be the name of the static folder
a
it can be anything but by default it's "static"
you can simply set it by using
#[shuttle_static_folder::StaticFolder(folder = "foo")] static_folder: PathBuf
like so
r
thanks
let me try and then i'll give you the inputs
a
no problem, it should work now - v0.11.3 of
shuttle_static_folder
has some unintentional bugs with accidentally deleting the static folder but it should get fixed soonish hopefully
r
hmm...
I am still getting the same error
does this crate offer something that I have to use in my lib.rs?
a
yeah you need to declare it in your main entrypoint function, i'll just grab a snippet from one of my projects and show you
Copy code
#[shuttle_service::main]
async fn axum(
    #[shuttle_static_folder::StaticFolder] static_folder: PathBuf,
    #[shuttle_shared_db::Postgres] postgres: PgPool,
    #[shuttle_secrets::Secrets] secrets: SecretStore,
) -> shuttle_service::ShuttleAxum {
... etc etc etc
r
ohk thx
let me try
the problem's that it works in my system but not on the server
a
do you have a link to a repo for your code by any chance?
r
sorry, its proprietry
a
ah I see, right
the next thing I can think of is either maybe try using
cargo shuttle project rm
and then
cargo shuttle project new --idle-minutes=0
so your project doesn't go to sleep (and then try deploying again)
r
ohk
I am seeing this: No resources are linked to this service
a
do you get anything at the hosted url? this message mostly relates to provisioned database resources if you need any
r
no dont need it
I Have a static folder in which I have index.html, xyz.css, etc
a
what do you get when you go to your deployed webservice's url?
r
On index I get: os error 3 no such file or directory
a
hmmmmm is your static file route on your actual actix-web router based at "/"?
r
no, its on /static.... actually I am using NamedFile::open_async to serve html page
a
what happens if you try to go to /static?
r
it shows
Copy code
Index file:
xyz.css
index.html
someimagefiles
Oh! , the problem is that it is removing everything in my html file as soon as I run my project
a
are you on
v0.11.3
of
shuttle-static-folder
on your Cargo.toml?
r
noo
I am on v0.11.0
shuttle-static-folder = "0.11.0"
a
oh I see, that's not good :| i think this may be to do with the current bugs with the static folder lib then
i'm assuming if you try to go to /static/index.html it's blank right?
r
yes
its blank again
but, on my local system it is working perfectly
a
that's strange - my axum static files work fine
i'll try making a quick actix-web project and see if i can get it to work for you
r
.service( fs::Files::new("/", "./static") .show_files_listing() .prefer_utf8(true) .index_file("./index.html") ); now i switched over to this
is there something wrong with this?
where fs is actix_static
a
i'm just quickly checking something
r
I mean actix_files
a
normally, you need to use the variable from the shuttle_static_folder macro to get access otherwise it tends to show up as blank
r
Like I just need to add it in the .service thingy
how to add it in .service?
a
hmmmm, I'll get back to you on this shortly
r
ok thx
cfg.service( web::resource("/").route(web::get().to(static_folder)) );
a
hmmmm I actually have no idea why this is happening, I just tried this myself - I'll relay this issue to the engineering team and see what they say - they will probably be able to respond to this properly on monday
r
is it working for you?
a
no it seems to be happening for me as well, I'll let the engineering team know this is happening. I'm not sure whether or not this is related to the recent static folder release since my static files work fine on axum
r
hmm...
The things is that I copied code from the shuttle actix example to serve html pages. as expected, it worked fine on my local system but, after deploying it ain't working.
I was able to figure out why this is happening: The resource from “example.com/example.css” was blocked due to MIME type (“”) mismatch (X-Content-Type-Options: nosniff)
a
you probably need to set the mime type - looks like this should hopefully solve it: https://stackoverflow.com/questions/75182522/how-to-send-html-css-and-javascript-together
r
why is this not working:
Copy code
rust
async fn index() -> impl Responder {
    NamedFile::open_async("./static/index.min.html").await
}

// .... 
.service(web::resource("/").route(web::get().to(index)));
I tried but still not working
I need explaination on this.... this works fine in laptop but not on server.
a
not sure, I've paged the engineering team but it is probably going to take some time before they can give an answer as they aren't actually in at the moment - apologies for any inconvenience
r
np
2 Views