R
Railway2y ago
nr

Unable to run railway run

In railway-cli version railwayapp 3.3.1 in a linked project and service, when I try to run a railway run command it just run locally. My project is a Docker project with a different docker file that the default one. It does not matter if a run within a subshell (railway shell) or not. I already tried docker commands, unix commands and web server commands (rails) and nothing works. Am I doing something wrong?
34 Replies
Percy
Percy2y ago
Project ID: 56a79696-4ad8-425e-8418-c891a338c23c
nr
nrOP2y ago
56a79696-4ad8-425e-8418-c891a338c23c
Brody
Brody2y ago
no you're not doing anything wrong railway run only runs commands locally, it first pulls the environment variables from your railway service and then runs the given command locally with the service variables now available same with railway shell it is a local shell, just with the variables from the railway service added
nr
nrOP2y ago
Thank you Brody !. It is possible to run the command inside the Docker container??.
Brody
Brody2y ago
it is not, but tell me the command you want to run and maybe I can come up with a solution for you
nr
nrOP2y ago
Sure!, I'm running a dockerized rails application. I'm looking to have a rails console, so the command for that usually is.
docker exec -it container_id rails console
docker exec -it container_id rails console
Brody
Brody2y ago
im not a ruby/rails dev so could you help me to understand what a rails console does/achieves?
nr
nrOP2y ago
sure, rails console lets you interact with a rails application within the terminal
Brody
Brody2y ago
interact how like what is the ultimate end goal here
nr
nrOP2y ago
Is a REPL
Brody
Brody2y ago
dont know what that is
nr
nrOP2y ago
ok, so I'll give you an example
nr
nrOP2y ago
How To Use the Node.js REPL | DigitalOcean
The Node.js Read-Eval-Print-Loop (REPL) is an interactive shell that processes Node.js expressions. The shell reads JavaScript code the user enters, evaluate…
nr
nrOP2y ago
is kind of similar in ruby but with the entire application loaded so you can execute ORM / database commands, explore the application and do troubleshooting basically you are interacting with your application with console
Brody
Brody2y ago
got it, but specifically what do you want to execute
nr
nrOP2y ago
e.g. I want to re-send an email to a user that didn't receive the email. with rails console I can do something like.
docker exec -it container_id rails console

# The interactive console is open
> User.find_by(email: '[email protected]').send_welcome_email
docker exec -it container_id rails console

# The interactive console is open
> User.find_by(email: '[email protected]').send_welcome_email
angelo
angelo2y ago
yep, so you will need to do something like rails console but we don't let you SSH in yet (soon, as a former Rails dev, I understand the need to)
nr
nrOP2y ago
Hi Angelo, thank you. That would be awesome.
Brody
Brody2y ago
for now i think you would need to implement something like that in an api endpoint
angelo
angelo2y ago
that or under /admin routes
nr
nrOP2y ago
Is there a way of execute rake tasks? or bash scripts?
angelo
angelo2y ago
rake on init but no, you should think as deploys as final cuts of your code
nr
nrOP2y ago
I understand, that's the way. I'm exploring what kind of things I can do developers can make mistakes, and I would like to understand if there is a way to troubleshoot cases with exceptions.
angelo
angelo2y ago
I get it but jumping into the running state of the app atm isn't how we currently support the debugging loop
angelo
angelo2y ago
anyway hope this helps and you can upvote a similiar feature request over at https://feedback.railway.app
Railway Feedback
Give feedback to the Railway team so we can make more informed product decisions. Powered by Canny.
nr
nrOP2y ago
sure, you guys are doing an amazing job, would be good if you can release that soon I'll vote for sure so basically railway run is not working in a Dockerized application atm.
Brody
Brody2y ago
as stated above, railway run is for running commands locally only
nr
nrOP2y ago
do you have documentation with some examples? just to understand better the use cases
Brody
Brody2y ago
from railway --help
run Run a local command using variables from the active environment
shell Open a local subshell with Railway variables available
run Run a local command using variables from the active environment
shell Open a local subshell with Railway variables available
the docs talk about it a bit more https://docs.railway.app/develop/cli#local-development
nr
nrOP2y ago
I'll run node and rails applications, dockerized and non dockerized, so would be good to have a better understanding of that.
Brody
Brody2y ago
thats about all the information i have on the matter
nr
nrOP2y ago
ok, I think I can run rails console pointing into the production database with that. I don't need to jump into the docker container. So that can help. I'll let you know If I have succeed with that.
Brody
Brody2y ago
yeah that should be do-able for database related actions
nr
nrOP2y ago
Ok, I was able to run rails console with railway executing the following command
railway run rails console -e production
railway run rails console -e production
Hope this can help someone else.
Want results from more Discord servers?
Add your server