add option to customize install script (bun)

10 months ago

In the new release of bun, with isolated installs. I started having issues with optional specific dependencies (OS related), since I can't customize the install script, I need to manually add them. It would be good if railway passed those info to bun install (via os and arch options) or allow us to pass it ourselves.

Solved$10 Bounty

61 Replies

10 months ago

You can install dependencies with environmental variables! Check out the build variables: https://railpack.com/config/environment-variables/#build-configuration



10 months ago

I can't view your deployments. Can you share the error and logs?


10 months ago

sure thing


10 months ago

Bun v1.3.0 (Linux x64 baseline)
error: "react-router-serve" exited with code 1
error: script "start" exited with code 1
error: script "start" exited with code 1
$ cd ./apps/app && bun start
$ bun --bun react-router-serve ./build/server/index.js
80871 |     }
80872 |     help.push(
80873 |       "- Consult the installation documentation:",
80874 |       "    See https://sharp.pixelplumbing.com/install"
80875 |     );
80876 |     throw new Error(help.join("\n"));
                      ^
error: Could not load the "sharp" module using the linux-x64 runtime
undefined: Could not dynamically require "../src/build/Release/sharp-linux-x64.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.

10 months ago

undefined: Could not dynamically require "../src/build/Release/sharp-wasm32.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
undefined: Could not dynamically require "@img/sharp-linux-x64/sharp.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
undefined: Could not dynamically require "@img/sharp-wasm32/sharp.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
      at requireSharp (/app/apps/app/build/server/assets/server-build-IAOUVDo1.js:80876:15)
      at requireConstructor (/app/apps/app/build/server/assets/server-build-IAOUVDo1.js:80888:3)
      at requireLib (/app/apps/app/build/server/assets/server-build-IAOUVDo1.js:85323:17)
      at /app/apps/app/build/server/assets/server-build-IAOUVDo1.js:85335:18
Bun v1.3.0 (Linux x64 baseline)
error: "react-router-serve" exited with code 1
error: script "start" exited with code 1
error: script "start" exited with code 1

10 months ago

I am running a custom install command: bun install --os "*" --cpu "*"


10 months ago

Is this project open source?


10 months ago

sadly no


10 months ago

This happens during deployment I assume?


10 months ago

yes, it works locally with the same commands that I run on railway, so I dont know whats the difference here


10 months ago

it builds and it deploys, but when it tries to run (deploy logs), it happens those errors


10 months ago

{
    "name": "@repo/domains",
    "version": "1.0.0",
    "private": true,
    "type": "module",
    "exports": {
        ".": "./src/domains/index.ts",
        "./*": "./src/domains/*/index.ts",
        "./server": "./src/server.ts",
        "./utils/*": "./src/utils/*.ts"
    },
    "license": "MIT",
    "scripts": {
        "verify": "biome check --error-on-warnings ./src",
        "db": "bun --bun --env-file=../../.env --env-file=../../.env.local drizzle-kit",
        "test": "bun test"
    },
    "devDependencies": {
        "@faker-js/faker": "^10.0.0",
        "@types/cookie": "^1.0.0",
        "@types/react": "catalog:react",
        "@types/three": "catalog:3d",
        "drizzle-kit": "^0.31.5",
        "typescript": "catalog:general"
    },
    "dependencies": {
        "@gltf-transform/core": "^4.2.1",
        "@gltf-transform/extensions": "^4.2.1",
        "@gltf-transform/functions": "^4.2.1",
        "@img/sharp-linux-x64": "^0.34.4",
        "drizzle-cuid2": "2.1.0",
        "drizzle-orm": "^0.44.6",
        "gltf-validator": "^2.0.0-dev.3.10",
        "lucide-react": "catalog:react",
        "meshoptimizer": "^0.25.0",
        "react": "catalog:react",
        "react-router": "catalog:react",
        "sharp": "^0.34.4"
    }
}

10 months ago

Have you tried using bun install --include=optional --force --os=linux --cpu=x64

And what variable are you using to set this?


10 months ago

env var: RAILPACK_INSTALL_CMD


10 months ago

deploying new changes to see if it work


10 months ago

@Sam (Loudbook) same error sadly


10 months ago

<:sadJoe:828937686026158100>


10 months ago

I am starting to wonder if its an railway issue, because its building and deploying locally with no issues


10 months ago

Less Railway issue more just running in an isolated environment issue


10 months ago

I would expect it to happen in any VM


10 months ago

hm, maybe if I add it as a global dependency or a root one?


10 months ago

Let's just try one modification of that command I sent earlier just to make sure


10 months ago

1 sec


10 months ago

Just add the word sharp to the end of it


10 months ago

bun install --include=optional --force --os=linux --cpu=x64 sharp


10 months ago

running it


10 months ago

Or wait it probably gets removed when it goes into the runtime container...


10 months ago

Hold on


10 months ago

If that doesn't work try changing your start command to

bun add sharp --force --include=optional --os=linux --cpu=x64 && bun start

10 months ago

it looks like that worked


10 months ago

i got an error from a different package


10 months ago

What's that package now 👀


10 months ago

draco3d


10 months ago

Can you share the new error


10 months ago

Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_decoder.wasm')
Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_encoder.wasm')
failed to asynchronously prepare wasm: RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_decoder.wasm'). Build with -sASSERTIONS for more info.
Aborted(RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_decoder.wasm'). Build with -sASSERTIONS for more info.)
failed to asynchronously prepare wasm: RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_encoder.wasm'). Build with -sASSERTIONS for more info.
Aborted(RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_encoder.wasm'). Build with -sASSERTIONS for more info.)
80896 |         function f2(e) {
80897 |           if (a.onAbort) a.onAbort(e);
80898 |           e = "Aborted(" + e + ")";
80899 |           da(e);
80900 |           wa = true;
80901 |           e = new WebAssembly.RuntimeError(e + ". Build with -sASSERTIONS for more info.");
                      ^
RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '/app/apps/app/build/server/assets/draco_decoder.wasm'). Build with -sASSERTIONS for more info.
      at f2 (/app/apps/app/build/server/assets/server-build-CYEA_q8Q.js:80901:15)
      at q (/app/apps/app/build/server/assets/server-build-CYEA_q8Q.js:80911:13)

10 months ago

everything was working fine on bun 1.2.23


10 months ago

this is so annoying


10 months ago

bun install --include=optional --force --os=linux --cpu=x64 sharp draco3d


10 months ago

Try it!


10 months ago

is there a way to do this through package.json? I hate messing with something platform specific


10 months ago

that worked!


10 months ago

Unfortunately I don't see a way to modify the install command in package json


10 months ago

Yay!


10 months ago

But honestly the method you just did should be fine- the issue may not be present on other platforms.


10 months ago

do you think there's any chance railway will allow us to customize install command through the settings page instead of a env var?


10 months ago

Doubt it


10 months ago

But you're using the UI to set the variable- right?


10 months ago

Not using a .env file?


10 months ago

yeah, saw the recommendation through this message


10 months ago

If you're putting it in the variables tab then it's in the right place

1427123249095118889


10 months ago

but its kinda missleading, because the dependencies installed are for mises, not node/npm/bun


10 months ago

¯_(ツ)_/¯


10 months ago

You can modify the docs and make a pull request if you'd like


10 months ago

I can't speak on the specifics of the Node install process. I pretty much just fed you google search results.


10 months ago

the issue was the bot answer actually


10 months ago

but I think I could also put it in the railpack.json file:

https://railpack.com/config/file


10 months ago

it allows for a custom command for install too


10 months ago

anyway, thanks for the help!


10 months ago

Oh sorry. I didn't even read that.


10 months ago

No problem!


Status changed to Open brody 10 months ago


Status changed to Solved brody 10 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...