installing libreoffice
willkessler
HOBBYOP

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?

Solved

65 Replies

willkessler
HOBBYOP

a year ago

7ff52821-b7d2-459c-bff8-3f070394a82b


willkessler
HOBBYOP

a year ago

hmm., maybe this should be in my build section after all? what does the deploy section do?


adam
MODERATOR

a year ago

Creating a nixpacks.toml file with libreoffice as a library should be the way to go



adam
MODERATOR

a year ago

Looks like libreoffice's nix library name is just libreoffice


willkessler
HOBBYOP

a year ago

ok. this is in addition to railway.toml yeah


willkessler
HOBBYOP

a year ago

?


adam
MODERATOR

a year ago

Yep!


willkessler
HOBBYOP

a year ago

is there a sample file somewhere i can reference? i'm a little unclear on which phase to put this under


adam
MODERATOR

a year ago

likely the install phase


willkessler
HOBBYOP

a year ago

or just:

[phases.install]
cmds = ['apt-get install libreoffice']

adam
MODERATOR

a year ago

Not apt get install, please read the docs


adam
MODERATOR

a year ago

You just need to include the name of the library


willkessler
HOBBYOP

a year ago

ok i see, so

[phase.install]
  aptPkgs = ['libreoffice']

adam
MODERATOR

a year ago

Yes, that's correct


willkessler
HOBBYOP

a year ago

thank you! giving it a whirl


adam
MODERATOR

a year ago

Add a '…' before libreoffice to include any auto detected packages if you have any issues


willkessler
HOBBYOP

a year ago

it's building… let's see what it does!


willkessler
HOBBYOP

a year ago

🤔 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 ║

╚══════════════════════════════════════════════════════════════════════════════╝```


adam
MODERATOR

a year ago

That build command is… a lot


adam
MODERATOR

a year ago

Not necessarily, no


willkessler
HOBBYOP

a year ago

claude just suggeste dusing phase.setup instead of phase.install. i'll experiment


willkessler
HOBBYOP

a year ago

the build command is a lot bc… monorepo 😆


adam
MODERATOR

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"


adam
MODERATOR

a year ago

fair enough!


willkessler
HOBBYOP

a year ago

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


willkessler
HOBBYOP

a year ago

aha, now i am getting something

╔══════════════════════════════ Nixpacks v1.31.0 ══════════════════════════════╗

║ setup      │ libreoffice, qpdf                                               

willkessler
HOBBYOP

a year ago

that's with this nixpacks:

[phases.setup]
nixPkgs = ["libreoffice", "qpdf"]

[start]
cmd = "cd packages/$RAILWAY_SERVICE && pnpm start"

adam
MODERATOR

a year ago

Great!


willkessler
HOBBYOP

a year ago

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?


adam
MODERATOR

a year ago

Sounds like a reasonable separation to me


willkessler
HOBBYOP

a year ago

🫰


willkessler
HOBBYOP

a year ago

er, 🤞


willkessler
HOBBYOP

a year ago

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


adam
MODERATOR

a year ago

Can you add Node as a provider in your service settings/nixpacks.toml?


willkessler
HOBBYOP

a year ago

trying it


willkessler
HOBBYOP

a year ago

error: undefined variable 'node'
at /app/.nixpacks/nixpkgs-5624e1334b26ddc18da37e132b6fa8e93b481468.nix:19:21:
18| '')
19| libreoffice node qpdf
| ^
20| ];

should I have put Node ? 🙂


willkessler
HOBBYOP

a year ago

my nixpacks.toml has
``` # File: nixpacks.toml

Adding system packages needed for document conversion

[phases.setup]
nixPkgs = ["node", "libreoffice", "qpdf"]
```


willkessler
HOBBYOP

a year ago

or maybe it should be "nodejs" ?


willkessler
HOBBYOP

a year ago

aha! that time it built… testing


willkessler
HOBBYOP

a year ago

sadly.. still can't find the executable. argh


willkessler
HOBBYOP

a year ago

is there an easy way to get inside my container and see where soffice was installed?


willkessler
HOBBYOP

a year ago

i'm trying to use railway shell to get inside the container but i cant seem to connect… any and all tips appreciated


adam
MODERATOR

a year ago

Unfortunately no. Railway does not support ssh-ing into your project


adam
MODERATOR

a year ago

You could echo the path somehow?


willkessler
HOBBYOP

a year ago

oh. i thought maybe railway run locate might work but it seems to just run things on my local


willkessler
HOBBYOP

a year ago

or maybe a way to see that its shell search path might be… maybe it doesn't include /usr/bin somehow (seems unlikely but…)


adam
MODERATOR

a year ago

Railway run effectively just injects the service variables into your local environment. It's not a shell


willkessler
HOBBYOP

a year ago

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-wrapped

which makes me think it installed libre ok


adam
MODERATOR

a year ago

It seems like your build process is very specific. Have you considered setting up a Dockerfile rather than relying on nixpacks?


adam
MODERATOR

a year ago

Nixpacks is great for automatically setting up "simple" apps, but Dockerfiles are more reliable for complex apps


willkessler
HOBBYOP

a year ago

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


adam
MODERATOR

a year ago

Understood


adam
MODERATOR

a year ago

If libreoffice is in your nixpacks.toml it's very likely that it did successfully install


adam
MODERATOR

a year ago

Unfortunately I'm not sure how you could find the location of the exec


willkessler
HOBBYOP

a year ago

i'm trying this build hack

echo "Looking for soffice..." && \
  find / -name soffice 2>/dev/null && \
  echo "Soffice search complete." && \

adam
MODERATOR

a year ago

Here's hoping it works!


willkessler
HOBBYOP

a year ago

in theory if it's on the image we'll find it… lolz. useful info for the next schlub


willkessler
HOBBYOP

a year ago

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/soffice

willkessler
HOBBYOP

a year ago

is that where you'd expect it?


adam
MODERATOR

a year ago

No clue, honestly. Give it a shot


willkessler
HOBBYOP

a year ago

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


adam
MODERATOR

a year ago

Very glad you got it working! Marking this thread as solved


adam
MODERATOR

a year ago

Good luck on the launch tomorrow!


adam
MODERATOR

a year ago

!s


Status changed to Solved adam about 1 year ago


Loading...