installing libreoffice

willkesslerHOBBY

5 months 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

0 Replies

willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months ago

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


5 months ago

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



5 months ago

Looks like libreoffice's nix library name is just libreoffice


willkesslerHOBBY

5 months ago

ok. this is in addition to railway.toml yeah


willkesslerHOBBY

5 months ago

?


5 months ago

Yep!


willkesslerHOBBY

5 months ago

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


5 months ago

likely the install phase


willkesslerHOBBY

5 months ago

or just:

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

5 months ago

Not apt get install, please read the docs


5 months ago

You just need to include the name of the library


willkesslerHOBBY

5 months ago

ok i see, so

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

5 months ago

Yes, that's correct


willkesslerHOBBY

5 months ago

thank you! giving it a whirl


5 months ago

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


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months 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 ā•‘

ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•```


5 months ago

That build command is… a lot


5 months ago

Not necessarily, no


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months ago

the build command is a lot bc… monorepo šŸ˜†


5 months ago

the difference between phases is pretty arbitrary. It comes down to "if you need x before y, put it in the phase before"


5 months ago

fair enough!


willkesslerHOBBY

5 months 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


willkesslerHOBBY

5 months ago

aha, now i am getting something

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

ā•‘ setup      │ libreoffice, qpdf                                               

willkesslerHOBBY

5 months ago

that's with this nixpacks:

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

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

5 months ago

Great!


willkesslerHOBBY

5 months 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?


5 months ago

Sounds like a reasonable separation to me


willkesslerHOBBY

5 months ago

🫰


willkesslerHOBBY

5 months ago

er, šŸ¤ž


willkesslerHOBBY

5 months 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


5 months ago

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


willkesslerHOBBY

5 months ago

trying it


willkesslerHOBBY

5 months ago

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

should I have put Node ? šŸ™‚


willkesslerHOBBY

5 months ago

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

Adding system packages needed for document conversion

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


willkesslerHOBBY

5 months ago

or maybe it should be "nodejs" ?


willkesslerHOBBY

5 months ago

aha! that time it built… testing


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months ago

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


5 months ago

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


5 months ago

You could echo the path somehow?


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months 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…)


5 months ago

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


willkesslerHOBBY

5 months 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


5 months ago

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


5 months ago

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


willkesslerHOBBY

5 months 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


5 months ago

Understood


5 months ago

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


5 months ago

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


willkesslerHOBBY

5 months ago

i'm trying this build hack

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

5 months ago

Here's hoping it works!


willkesslerHOBBY

5 months ago

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


willkesslerHOBBY

5 months 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

willkesslerHOBBY

5 months ago

is that where you'd expect it?


5 months ago

No clue, honestly. Give it a shot


willkesslerHOBBY

5 months 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


5 months ago

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


5 months ago

Good luck on the launch tomorrow!


5 months ago

!s


Status changed to Solved adam • 5 months ago


installing libreoffice - Railway Help Station