2 years ago
Hi, I'm reliant on soffice for some pdf manipulations in my service. I'm trying to get libreoffice installed via my railway.toml flie, but i suspect the installation isn't happening.
i have this section in my railway.toml :
[deploy]
installCommand = """
apt-get update && \
apt-get install -y qpdf libreoffice && \
pnpm install
"""but i don't see this installation happening in my build log and /usr/bin/soffice and /usr/lib/libreoffice/program/soffice don't exist after the service is up.
Any clues on how to do this right? is sudo needed during these install steps?
65 Replies
hmm., maybe this should be in my build section after all? what does the deploy section do?
2 years ago
Creating a nixpacks.toml file with libreoffice as a library should be the way to go
2 years ago
2 years ago
Looks like libreoffice's nix library name is just libreoffice
2 years ago
Yep!
is there a sample file somewhere i can reference? i'm a little unclear on which phase to put this under
2 years ago
likely the install phase
2 years ago
Not apt get install, please read the docs
2 years ago
You just need to include the name of the library
2 years ago
Yes, that's correct
2 years ago
Add a '...' before libreoffice to include any auto detected packages if you have any issues
š¤ would it show up as a step during build? I don't see it mentioned
context: 51c94a4d2ceed7b888b5c73f7d4fe9ff
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā Nixpacks v1.31.0 āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā setup ā nodejs_18, pnpm-9_x ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā install ā npm install -g corepack@0.24.1 && corepack enable ā
ā ā pnpm i --frozen-lockfile ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā build ā corepack enable && corepack prepare pnpm@8.15.1 --activate && ā
ā ā pnpm install && cd packages && cd common && pnpm build && cd .. ā
ā ā && cd jobs && pnpm build && cd .. && cd ai && pnpm build && cd ā
ā ā .. && if [ "$NODE_ENV" = "development" ]; then echo "Skipping ā
ā ā builds in development mode"; else if [ "$RAILWAY_SERVICE" = ā
ā ā "dashboard" ]; then cd dashboard && pnpm build; elif [ ā
ā ā "$RAILWAY_SERVICE" = "jobs" ]; then echo "jobs package already ā
ā ā built"; elif [ "$RAILWAY_SERVICE" = "api" ]; then cd api && ā
ā ā pnpm build; fi; fi ā
ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā start ā cd packages/$RAILWAY_SERVICE && pnpm start ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā```
2 years ago
That build command is... a lot
2 years ago
Not necessarily, no
claude just suggeste dusing phase.setup instead of phase.install. i'll experiment
2 years ago
the difference between phases is pretty arbitrary. It comes down to "if you need x before y, put it in the phase before"
2 years ago
fair enough!
it turns out that it didn't install. or at least it's not in the places i'd expect. i'll try claude's idea next
aha, now i am getting something
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā Nixpacks v1.31.0 āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā setup ā libreoffice, qpdf that's with this nixpacks:
[phases.setup]
nixPkgs = ["libreoffice", "qpdf"]
[start]
cmd = "cd packages/$RAILWAY_SERVICE && pnpm start"2 years ago
Great!
but unfortunately this messes up my start.. suddenly can't find npm. which i don't use. however, that could be the [start] block. gonna remove that from nixpacks.toml since it worked fine before with the start in railway.toml. hopefully this prereq stuff can live in nixpacks and everything else in railway.toml?
2 years ago
Sounds like a reasonable separation to me
looks like separation doesn't work. now that there's a nixpacks.toml, it's trying to use this command:
npm install -g corepack@0.24.1 && corepack enable ā
ā ā pnpm i --frozen-lockfile which fails almost immediately
2 years ago
Can you add Node as a provider in your service settings/nixpacks.toml?
error: undefined variable 'node'
at /app/.nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix:19:21:
18| '')
19| libreoffice node qpdf
| ^
20| ];
should I have put Node ? š
my nixpacks.toml has
# Adding system packages needed for document conversion
[phases.setup]
nixPkgs = ["node", "libreoffice", "qpdf"]is there an easy way to get inside my container and see where soffice was installed?
i'm trying to use railway shell to get inside the container but i cant seem to connect... any and all tips appreciated
2 years ago
Unfortunately no. Railway does not support ssh-ing into your project
2 years ago
You could echo the path somehow?
oh. i thought maybe railway run locate might work but it seems to just run things on my local
or maybe a way to see that its shell search path might be... maybe it doesn't include /usr/bin somehow (seems unlikely but...)
2 years ago
Railway run effectively just injects the service variables into your local environment. It's not a shell
i was hoping there could be a railway equivalent of docker run -it to poke around. well, i can also add a boatload of likely paths... just could take me a long time to find it.
during the build i saw it did these:
/nix/store/agx7qlqb4cd6f4mv4ngvcd6p1mjrk7gf-libreoffice-24.2.7.2
/nix/store/zkb5z6q718n8d1pmvii00w2hspdix4zr-libreoffice-24.2.7.2-wrappedwhich makes me think it installed libre ok
2 years ago
It seems like your build process is very specific. Have you considered setting up a Dockerfile rather than relying on nixpacks?
2 years ago
Nixpacks is great for automatically setting up "simple" apps, but Dockerfiles are more reliable for complex apps
i am open to it yeah. i did that on my last railway project. unfortunately, we're launching tomorrow so i don' thave time to switch tonight
2 years ago
Understood
2 years ago
If libreoffice is in your nixpacks.toml it's very likely that it did successfully install
2 years ago
Unfortunately I'm not sure how you could find the location of the exec
i'm trying this build hack
echo "Looking for soffice..." && \
find / -name soffice 2>/dev/null && \
echo "Soffice search complete." && \2 years ago
Here's hoping it works!
in theory if it's on the image we'll find it... lolz. useful info for the next schlub
weird, what's this mean?
/nix/store/7v64r0f3awpkbcr08k4win1lp9d3b1xw-user-environment/bin/soffice
/nix/store/lsgbh1xzdkccng60kpfwqkiy82fq9c6r-5624e1334b26ddc18da37e132b6fa8e93b481468-env/bin/soffice
/nix/store/agx7qlqb4cd6f4mv4ngvcd6p1mjrk7gf-libreoffice-24.2.7.2/lib/libreoffice/program/soffice
/nix/store/zkb5z6q718n8d1pmvii00w2hspdix4zr-libreoffice-24.2.7.2-wrapped/lib/libreoffice/program/soffice
/nix/store/zkb5z6q718n8d1pmvii00w2hspdix4zr-libreoffice-24.2.7.2-wrapped/bin/soffice2 years ago
No clue, honestly. Give it a shot
holy crap, it works. well, that was a giant hack. but... my code does a seaerch through /nix/store to find soffice so it can run it. welp... after this launch i'm gonna switch to dockerfiles that i can understand better. thanks for your help today. as usual, i still love working with Railway
2 years ago
Very glad you got it working! Marking this thread as solved
2 years ago
Good luck on the launch tomorrow!
2 years ago
!s
Status changed to Solved adam ⢠over 1 year ago