a year 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?
a year ago
Creating a nixpacks.toml file with libreoffice as a library should be the way to go
a year ago
Looks like libreoffice's nix library name is just libreoffice
a year ago
Yep!
is there a sample file somewhere i can reference? i'm a little unclear on which phase to put this under
a year ago
likely the install phase
a year ago
Not apt get install, please read the docs
a year ago
You just need to include the name of the library
a year ago
Yes, that's correct
a year 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 │ nodejs18, pnpm-9x ║
║──────────────────────────────────────────────────────────────────────────────║
║ 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 ║
╚══════════════════════════════════════════════════════════════════════════════╝```
a year ago
That build command is… a lot
a year ago
Not necessarily, no
claude just suggeste dusing phase.setup instead of phase.install. i'll experiment
a year ago
the difference between phases is pretty arbitrary. It comes down to "if you need x before y, put it in the phase before"
a year 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"a year 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?
a year 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
a year 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
``` # File: nixpacks.toml
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
a year ago
Unfortunately no. Railway does not support ssh-ing into your project
a year 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…)
a year 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
a year ago
It seems like your build process is very specific. Have you considered setting up a Dockerfile rather than relying on nixpacks?
a year 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
a year ago
Understood
a year ago
If libreoffice is in your nixpacks.toml it's very likely that it did successfully install
a year 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." && \a year 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/sofficea year 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
a year ago
Very glad you got it working! Marking this thread as solved
a year ago
Good luck on the launch tomorrow!
a year ago
!s
Status changed to Solved adam • about 1 year ago