R
Railway17mo 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
Percy17mo ago
Project ID: 56a79696-4ad8-425e-8418-c891a338c23c
nr
nr17mo ago
56a79696-4ad8-425e-8418-c891a338c23c
Brody
Brody17mo 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
nr17mo ago
Thank you Brody !. It is possible to run the command inside the Docker container??.
Brody
Brody17mo 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
nr17mo 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
Brody17mo ago
im not a ruby/rails dev so could you help me to understand what a rails console does/achieves?
nr
nr17mo ago
sure, rails console lets you interact with a rails application within the terminal
Brody
Brody17mo ago
interact how like what is the ultimate end goal here
nr
nr17mo ago
Is a REPL
Brody
Brody17mo ago
dont know what that is
nr
nr17mo ago
ok, so I'll give you an example
nr
nr17mo 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
nr17mo 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
Brody17mo ago
got it, but specifically what do you want to execute
nr
nr17mo 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
angelo17mo 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
nr17mo ago
Hi Angelo, thank you. That would be awesome.
Brody
Brody17mo ago
for now i think you would need to implement something like that in an api endpoint
angelo
angelo17mo ago
that or under /admin routes
nr
nr17mo ago
Is there a way of execute rake tasks? or bash scripts?
angelo
angelo17mo ago
rake on init but no, you should think as deploys as final cuts of your code
nr
nr17mo 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
angelo17mo ago
I get it but jumping into the running state of the app atm isn't how we currently support the debugging loop
angelo
angelo17mo 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
nr17mo 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
Brody17mo ago
as stated above, railway run is for running commands locally only
nr
nr17mo ago
do you have documentation with some examples? just to understand better the use cases
Brody
Brody17mo 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
nr17mo ago
I'll run node and rails applications, dockerized and non dockerized, so would be good to have a better understanding of that.
Brody
Brody17mo ago
thats about all the information i have on the matter
nr
nr17mo 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
Brody17mo ago
yeah that should be do-able for database related actions
nr
nr17mo 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