add option to customize install script (bun)

7 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

7 months ago

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



7 months ago

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


7 months ago

sure thing


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

7 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

7 months ago

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


7 months ago

Is this project open source?


7 months ago

sadly no


7 months ago

This happens during deployment I assume?


7 months ago

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


7 months ago

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


7 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"
    }
}

7 months ago

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

And what variable are you using to set this?


7 months ago

env var: RAILPACK_INSTALL_CMD


7 months ago

deploying new changes to see if it work


7 months ago

@Sam (Loudbook) same error sadly


7 months ago

<:sadJoe:828937686026158100>


7 months ago

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


7 months ago

Less Railway issue more just running in an isolated environment issue


7 months ago

I would expect it to happen in any VM


7 months ago

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


7 months ago

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


7 months ago

1 sec


7 months ago

Just add the word sharp to the end of it


7 months ago

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


7 months ago

running it


7 months ago

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


7 months ago

Hold on


7 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

7 months ago

it looks like that worked


7 months ago

i got an error from a different package


7 months ago

What's that package now 👀


7 months ago

draco3d


7 months ago

Can you share the new error


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

7 months ago

everything was working fine on bun 1.2.23


7 months ago

this is so annoying


7 months ago

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


7 months ago

Try it!


7 months ago

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


7 months ago

that worked!


7 months ago

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


7 months ago

Yay!


7 months ago

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


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


7 months ago

Doubt it


7 months ago

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


7 months ago

Not using a .env file?


7 months ago

yeah, saw the recommendation through this message


7 months ago

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

1427123249095118889


7 months ago

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


7 months ago

¯_(ツ)_/¯


7 months ago

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


7 months ago

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


7 months ago

the issue was the bot answer actually


7 months ago

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

https://railpack.com/config/file


7 months ago

it allows for a custom command for install too


7 months ago

anyway, thanks for the help!


7 months ago

Oh sorry. I didn't even read that.


7 months ago

No problem!


Status changed to Open brody 7 months ago


Status changed to Solved brody 7 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...