Cache mount ID is not prefixed with cache key
I'm trying to build a docker image with the recommended instructions from pnpm (https://pnpm.io/docker), adding
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
to my dockerfile, but when building on railway i'm getting a Cache mount ID is not prefixed with cache key
build error when building the docker image, which doesn't tell me much just from that.
Searching here, I found out this thread https://discord.com/channels/713503345364697088/1104400912149123152/1104400912149123152, which looks the same problem as mine, and that it was suggested to attach the service ID into the id part, which I did with the following:
And also this:
But I think this is still not the correct format, as both resulted in the same error. Am I formatting this wrong?
The service-id is 2d13c748-906b-4f06-bdbc-9a9cbdb84534Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
111 Replies
Project ID:
2d13c748-906b-4f06-bdbc-9a9cbdb84534,2d13c748-906b-4f06-bdbc-9a9cbdb84534,2d13c748-906b-4f06-bdbc-9a9cbdb84534
This also doesn't work
RUN --mount=type=cache,id=s/2d13c748-906b-4f06-bdbc-9a9cbdb84534-/root/pnpm,target=/root/pnpm/store pnpm install --frozen-lockfile
what's the default cache key look like as generated by nixpacks?
looks like its
RUN --mount=type=cache,id=s/2d13c748-906b-4f06-bdbc-9a9cbdb84534-/root/local/share/pnpm/store/v3,target=/root/.local/share/pnpm/store/v3 pnpm i --frozen-lockfile
, seems to be following the same pattern as my previous message, but using a different folder 🤔
I tried with that exact same one, and I still get the same error:
well any reason you arent just using nixpacks?
I was having a bug where after one random commit with just an unrelated package update it just refused to run the build script, it would just try to start right away, so docker gave me more confidence overall that it would do what I expect it to, and if it doesn't, I can easily reproduce it locally
also, i'm not very familiar with nixpacks, which also counts against ahahah
refused to run the build script?
yes, it would just apparently clone the repo and execute the run script. I did manage to make it work by attaching the build script to the start command, but that was way too hacky
if you have a build script in your package.json it will be ran
its what I would expect as well, but my app kept on crashing cause it wouldn't find the dist folder. when I copy and pasted the build command into the start command, then it start running fine
can you reproduce this?
guess I can try again, but I still do have some deployment logs, is that enough?
oh yeah lets see them https://bookmarklets.up.railway.app/log-downloader/
wait, I think that one is the one with the fix
that start command tho lol
me trying to debug lmao
you set that build command in the service settings right?
this is the one where the error started happening out of nowhere
yep
okay hold up
what is with these file names
this is one where it did work
(before that commit)
are you changing these file names?
which filenames?
the log file filenames
ah, not really, I guess discord randomizes it
no it doesnt?
where are your random names coming from
hmmm, weird, looks fine in here
but yeah, after the upload it gets randomized
i can try attaching it instead
or zipping it lol
you got something funky going on with your discord, doesnt matter, just wanted to know if my code was buggin
okay so most people who have turbo repos have specfic build and start commands to filter build and filter start an app
you are using cd, you never want to use cd
I also tried with filter, but i got the same result
can you share the repo
I'd prefer to avoid it if possible... tbh, I think theres some weird stuff going on on the railway project itself, as I mentioned, I was using nixpacks before, but switched to docker, and now the build command is gone from the UI, but its still displayed as set on the configs, even displaying a warning that its not supported (but I can't remove anyway)
yeah that's a UI bug
but the missing dist folder isn't a problem with nixpacks really, but more so how your project is configured
I do believe that could be the case, I just don't see how though. It was working fine until this commit, which just updates a package to a later version (no changes to the scripts, no changes to railway deploy config, etc)
after that all builds started failing
(the code isn't even related to the railway app, its for another package deployed on vercel)
id be happy to dive into this further but it's just gonna be me asking you a bunch of questions
and it started working again after I copy and pasted the build command into the start script (literally the same one)
yep, I understand, its a weird issue ahahah
in any case, I'm good now with docker, I just have that same problem with caching though
what are the build and start scripts in the bot's package.json?
"start": "node ./dist/src/index.js",
"build": "rimraf dist && tsc -p . --outDir dist",
what the heck is rimraf
its an npm package to do rm -rf in an os agnostic way
npm
rimraf
A deep deletion module for node (like
rm -rf
). Latest version: 5.0.5, last published: 16 days ago. Start using rimraf in your project by running npm i rimraf
. There are 20346 other projects in the npm registry using rimraf.okay but why lol
I have a friend developing on windows, so it has its quirks
doesn't hurt ahahah
you shouldn't have the dist folder in your github repo at all, and therefore it wouldn't be on railway and wouldn't be there when your friend pulls the repo
ahhh, yeah, I know, its just for local 😄
to make sure we clean the dir, to avoid having duplicated files (if you delete a file, it will still be on the build dir in the end if you don't clean it up. which can lead to all sorts of weird behaviours)
on deployments it should make no difference
doesn't tsc have an option to clean the dist folder for you?
if it does, I don't know, would be quite helpful ahahah
but yes you are right it wouldn't cause issues, it's just odd in this context
I think it only overrides the files
in your railway service what do you have the root dir set to
Its blank now, I think it was also blank when I was on nixpacks
at least I can't find the option on that deployment
okay blank is good
the last build that worked without issues, before you made that change in a different app, what version of nixpacks was it using?
it says Nixpacks v1.17.0 on the logs
okay so it's not anything railway changed since that's still the latest
in case its useful, this is the build logs from the build that worked before the one that started failing
can you show me the dist related error?
sure, this is the error:
this repeats over and over again, until the service gets to a crashed state and stops trying run again
I also do have logs for a deployment I made where the start script is
cd ./apps/bot && ls -lA && ls -lA dist && ls -lA dist/src && pnpm start
, to debug the contents of the file on the server, and this is the output:
again, this repeats over and overyou know why it's repeating right
its the restart policy I imagine
yep
the next deployment I tried doing this as the start command:
pnpm build --filter bot && cd ./apps/bot && ls -lA && ls -lA dist && ls -lA dist/src && pnpm start
. With this, the dist folder got properly populated, and I got the following output:so I imagine the dist folder is being created, just not put in the correct directory
(last one is the dist folder output)
this is why I imagine it just wasn't executing the build command, cause when I force it to, it does appear there
delete all local dist folder, cd into the root of your project and run the same build command as you have railway run, where is the dist folder placed?
heres me following the same steps locally, on the first ls theres no dist folder, and on the second one the dist folder is there, lastly the start command runs fine (the command failed at the end is just because I stopped it, but it gets executed)
fancy term
thanks 😄
why does the build mention astro?
isnt this a bot?
its a dependency for the bot, its actually another web app, but also contains some list files I import inside the bot, so turbo ends up also building it as well
I could create another package just for the lists to avoid building it when building the bot, but im a bit lazy to do that ahahah
try putting stuff back to how it should be but use filter in place of cd
ohhh, actually, I think I found the issue 😅
do tell
it happens when turborepo uses the cache, and I forgot to put the dist folder into the turborepo outputs parameters, so it just replays the logs, but doesn't actually put the dist folder on its place
it also makes sense why it happens on unrelated changes to another app, cause then it used the cache, and the dist folder was not there
interesting
if I add the correct configs, then it caches the folder correctly ahahah
i wasnt wrong lol
true ahahahah
still should use the filter flag
thank you for the help on debugging this, was quite an interesting ride 😄
please no more cd
yep, i'm doing that on the dockerfile
btw, going back to the dockerfile pnpm caching thing, do you have any idea why it complains when I try caching the pnpm folder like nixpacks do? I'd honestly still prefer to continue on using dockerfile, as its a bit easier to debug things locally and I have more familiarity with it...
no clue
but you can use nixpacks locally too
ahh, true, just saw on their docs... whats the benefits of using it vs for example, docker?
caching 🤣
makes sense 🤣 🤣
still confuses me why the same command works using nixpacks, but not on a docker image
you arent the first person to ask about that tbh
:/
the weird part is that locally using docker it works lol
let me see if i can get a dockerfile working with a cache id
yes i can
skill issue fr
oh, how did you fix it?
i just grabbed the dockerfile nixpacks generates and then copyed its cache stuff
its not a turbo app, but you get the idea
thats weird, looks the same as the one I have though
I copied mine from the nixpack build log that railway outputted
if i type my id wrong i get the same error
hmmm, is the ID supposed to be the project, or the service?
service id
should be the correct one then 🤔
(its the same one i used on the dockerfile)
also, I just copy and pasted the one nixpacks gave me, so it should behave the same I think
haha i dont know what to tell you, i can only get that error if i do something wrong with the id
how long does the build take on railway using nixpacks, and then with your dockerfile (omiting any caching)
42.20 sec on nixpacks and 36.90 seconds on docker...
lmao
problem solved
but those numbers are from builds on railway right?
ahh, no wait, I was looking at the publish times, the last number reported on the logs, but its around 1m30s on nixpacks, and 2 min on docker
not bad
filter the build further so it doesnt build the astro app too and you will be good to go