Rust app failing with `No such file or directory`
Basically i am trying to deploy a rust app that needs to read files that are part of the codebase. these files are checked in too. but the app is failing with
No such file or directory
I am deploying via the cli railway up
43 Replies
Project ID:
N/A
It appears that the issue is related to the .nixpacks directory not being able to find the Cargo.toml file.
⚠️ experimental feature
N/A
the app builds the application fine with the Cargo.toml. But on runtime, it doesnt seem to find a file
also
railway shell
doesn't seem to work even after doing railway link
run
railway -V
what version of cli are you running
*capital V btw3.0.1
upgrade
3.0.1 is bugged
curl -fsSL https://raw.githubusercontent.com/railwayapp/cli/master/install.sh | bash
upgraded to 3.0.3 but railway shell is just opening my own local in a different shell within
how to list the directory structure of the deployment? i think theres a mismatch in that
it is supposed to do that
it just injects your env vars into the shell
btw
for rust
just
include_as_str!
oh i thought its opens a shell in the container. mb
also railway storage is ephemeral
no persistent storage
if you need persistent storage spin up a postgres
or use a bucket
so programs on railway cannot do a fs read?
yes they can
they can read, not write i believe
i dont want to write
and between relaunches it will disappear
are you using relative file URIs?
they can read and write, its just anything you write gets wiped on next deploy
oh
i misunderstood
no worries
basically this is the dir structure i am doing
railway up
fromwhere is the file
the rust app is trying to read
./config/log4rs.yaml
ok
erm
i tried logging the path its trying to access and it prints this:
path: "/app/config/log4rs.yaml"
IDK how nixpacks handles that stuff
can you ls the foldr
see if the file is even there lmao
this is the code for that
i dont know how to do that. i was hoping railway shell logs me into that deployment container. but it doesnt
what kind of persistent application
rocket.rs?
whats the app even for
its basically just a web server but i am using log4rs and reading its config from that file
hmm no clue then
looking at the build logs, i suppose railway only copies the final executable from the build into the docker image and runs that. that doesn't include any of the other files
thats what i thought
you should use the rust macro
include_as_str!("path");
it will... include the file as an &strcan you point me to a doc for that? couldnt find it googling
nvm im studipd
istits just
include_str!();
i made a goof
my badinclude_str in std - Rust
Includes a UTF-8 encoded file as a string.
This macro will yield an expression of type &'static str which is the contents of the file.
but it still needs to read the file doesnt it?
it will do it during build time
macro will expand during build
oh okay. let me try
gl
awesome! that worked. thnx! 🙏 🙏
altho i suppose i cannot use any kind of variable or env var for the path in
include_str
can I?
i was planning to move that config file path to an env var or somethingsure you can
maybe not with include_str, but you can read the string from the env variable
yeah include_str requires it to be string literal
if you do it with env var
nothing will change
because the file will be sucked up at build time
and rust will not care at all