a year ago
We are trying to deploy Railway to production with command railway up -s <redacted> -e production
but it gets deployed to staging instead. If we use --verbose flag, we can see that environment ID changes in the output of the command compared to -e staging
but actual deployment is still created on staging environment.
We also tried to link the environment via railway environment production
and then running just railway up -s <redacted>
but it also deploys to wrong environment.
This feels like a bug but in case it's not, I'd like to learn how to deploy correctly.
11 Replies
a year ago
What version of the CLI are you running? if it's not the latest please try again with the latest version.
And instead of specifying the friendly names for the environment and service, try specifying their UUIDs instead.
ctrl / cmd + k
-> copy
Status changed to Awaiting User Response christian • 11 months ago
a year ago
So, I tried updating CLI and also using environment ID but nothing worked, deployments still go to staging. Terminal outputs
% RAILWAY_TOKEN=<redacted> railway up -s <redacted> -e production -d --verbose
Indexed Compressed [====================] 100% railway up
service: cf894097-dfb0-4c2f-990d-3390ac6dda0c
environment: 044a8124-83e0-4272-a651-04c8553d0d08
bytes: 896922
url: https://backboard.railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/environment/044a8124-83e0-4272-a651-04c8553d0d08/up?serviceId=cf894097-dfb0-4c2f-990d-3390ac6dda0c
Uploaded Build Logs: https://railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/service/cf894097-dfb0-4c2f-990d-3390ac6dda0c?id=f138df1e-ec64-4796-9466-4c2441f3780c&
% RAILWAY_TOKEN=<redacted> railway up -s <redacted> -e staging -d --verbose
Indexed Compressed [====================] 100% railway up
service: cf894097-dfb0-4c2f-990d-3390ac6dda0c
environment: b83e15ad-1dde-49c8-b9d3-647ba06e95bb
bytes: 896922
url: https://backboard.railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/environment/b83e15ad-1dde-49c8-b9d3-647ba06e95bb/up?serviceId=cf894097-dfb0-4c2f-990d-3390ac6dda0c
Uploaded Build Logs: https://railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/service/cf894097-dfb0-4c2f-990d-3390ac6dda0c?id=1cba33f0-f295-41e7-8a33-e6ee70947d5d&
% railway -V
railwayapp 3.11.0
% RAILWAY_TOKEN=<redacted> railway up -s <redacted> -e 044a8124-83e0-4272-a651-04c8553d0d08 -d --verbose
Indexed Compressed [====================] 100% railway up
service: cf894097-dfb0-4c2f-990d-3390ac6dda0c
environment: 044a8124-83e0-4272-a651-04c8553d0d08
bytes: 896922
url: https://backboard.railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/environment/044a8124-83e0-4272-a651-04c8553d0d08/up?serviceId=cf894097-dfb0-4c2f-990d-3390ac6dda0c
Uploaded Build Logs: https://railway.app/project/12827153-4b62-4810-bf73-7e4abb4af87a/service/cf894097-dfb0-4c2f-990d-3390ac6dda0c?id=d6c8b164-083d-4f58-b34b-0e7da9a49445&
I know it says in the output it's deploying to production but it's not actually. This is our production environment and you'll notice that just Github deployments are listed there.
Status changed to Awaiting Railway Response railway[bot] • 11 months ago
a year ago
Forgot to attach the screenshot :)
a year ago
Perhaps you have set a RAILWAY_TOKEN
environment variable that corresponds to the staging environment? as they are environment-specific.
Edit, just confirmed this myself, by specifying a RAILWAY_TOKEN
that was created for the staging environment the code will be uploaded to the corresponding service in the environment the token was created for, ignoring the --environment
flag.
Of course, ideally the CLI would fail when there's such a mismatch, but that is the issue either way.
a year ago
^ that makes sense since tokens are scoped to an environment. I think this should ideally result in an error instead of pushing to the environment the token has access to despite specifying another environment.
Status changed to Awaiting User Response railway[bot] • 11 months ago
a year ago
Oh god, yes, that was issue. Now that I visited Settings page for the second time, I see the UI is clear that token is scope to the environment but I created staging token some time ago and forgot it's scoped. Thank you for your help. (I agree that CLI error would prevent such PEBKAC issues :) )
And since I have your attention, may I suggest small improvement? Instead of saying just "railway up", deploy message could be something nicer, ideally a commit message, similar to automatic deployments.
Status changed to Awaiting Railway Response railway[bot] • 11 months ago
a year ago
Glad we where able to solve!
But I'm not sure how you could display a commit message if the deployment wasn't made by a GitHub source, railway up is only sending a tarball of your code and has no concept of where your code is coming from.
a year ago
Oh right, didn't think of how CLI is doing it.
Well, CLI most probably has access to Git repo too, so it could still get the HEAD and use that as deploy message. Idk, it was just a suggestion in case you didn't notice the ugly wall of "railway up"s. It sometimes takes second set of eyes to spot ugly sections of the product, that's why I spoke up.
btw, love the newish observability dashboard, keep up good work.
a year ago
I've filed an issue for us to fix that CLI behaviour (error-ing out when env token lacks access instead of pushing to the token's environment).
Gonna close this out, thanks for the report!
Status changed to Awaiting User Response railway[bot] • 11 months ago
Status changed to Solved ray-chen • 11 months ago
Status changed to Open brody • 11 months ago
Status changed to Solved brody • 11 months ago