Skill issue with
railway run

2 years ago

Having a skill issue.
I want to run a .js script remotely on Railway.
railway run npm run script works, but this is a node command that uses --env-file, and the .env file is not present after building the app.
Can I just run any remote file directly?

20 Replies

2 years ago

N/A


2 years ago

Is there any way to, during build time, add all the env vars from Railway into an .env file?


2 years ago

railway run only runs the given command locally.

can you explain the usecase please?


2 years ago

Oh, I've just misunderstood the command then


2 years ago

I thought it was actually running the script on the remote machine (Railway)


2 years ago

nope, but to understand your needs, can you tell us why instead of that what?


2 years ago

Now that I understand that it simply grabs the env vars(?), it's all good.
The use case is deploying slash commands of a Discord bot in the live environment


2 years ago

yeah railway run grabs the environment variables set in the service variables and injects them into a temporary environment that the given command runs in.

may I ask how railway run comes into play here? wouldn't you just make the necessary code changes to support slash commands and then push the changes to Github?


2 years ago

I use a set of scripts to actually deploy/update the slash commands

1269379300604383200


2 years ago

I've never done discord bot development, but that feels a little unconventional?


2 years ago

The alternative is to deploy commands on every start


2 years ago

In my experience, Discord doesn't invalidate the old commands until one of them are used


2 years ago

Which makes the first use return an error


2 years ago

and you can't run these commands locally? do they modify the filesystem?


2 years ago

If you mean the slash commands, they are used here in the Discord client


2 years ago

I mean those scripts


2 years ago

They don't modify any files. And now I know that I can run them locally with the Railway vars


2 years ago

yeah problem solved?


2 years ago

Pretty much


2 years ago

awesome


Loading...