2 months ago
I will occasionally need to edit a file in my project console. The console seems to be a fairly standard Linux shell, so I was surprised to find that vi is not present. How can I edit a text file?
1 Reply
2 months ago
The console opens a shell inside your service's container, so it only has the tools your image ships with. Many slim base images leave out vi.
The easiest way to edit a file is to copy it to your machine, change it locally, and copy it back. Our SSH endpoint supports scp and sftp: register a key with railway ssh keys add, then run scp [email protected]:/app/file.txt ./file.txt, edit the file, and copy it back the same way with the source and destination swapped. Use your service's domain as the username, or its service instance ID if it has no domain. You can also open an interactive session with sftp [email protected]. The full details are in the railway ssh docs.
If you'd rather edit in place, add an editor such as vim or nano to your image. Interactive tools like vim work in a railway ssh session.
Keep in mind that files you change in the container filesystem are lost on the next redeploy unless they are on a mounted volume.
Status changed to Awaiting User Response Railway • about 2 months ago
Status changed to Solved bruceh29 • about 2 months ago