How to run code in a Remote Environment?


So I have a freshly installed Gitlab instance and I have also created a Remote Environment as per this guidance: Tutorial: Connect a remote machine to the Web IDE | GitLab

I can open my Gitlab’s Web IDE and I can connect from there to the Remote Environment.

But then what? Even if I access the Web IDE to edit a specific file, after I connect to the Remote Environment, it is not there (like the rest of my Repo). Which makes sense, I guess, as this is another machine. But it is my understanding that I should be able to use the Remote Environment to run code hosted on Gitlab.

Am I mistaken? Or am I missing anything?


Thank you, Albert.

Either we are in complete alignment about how GitLab and the Remote Environment work together or I still don’t understand, because I agree with everything you said and still:

This is a small program in GitLab:
Bildschirmfoto 2023-08-01 um 13.32.49

This is the same program when I open it in the Web IDE:
Bildschirmfoto 2023-08-01 um 13.33.05

And this is what I get after I connect from the Web IDE to the Remote Environment:
Bildschirmfoto 2023-08-01 um 13.33.22

My file isn’t there. So how can I run it? This is where I struggle…

Anyone who can tell me how to run code a Remote Environment?

Any hints appreciated!


Seriously? Noone?

Google has a ton of results - this is a VS Code thing, has nothing to do with Gitlab. Did you actually try using google or some other search engine at all?

and this in particular:

step-by-step guide and even explains that once the remote connection is configured in VS Code, any new files created are created on the remote server. I guess you were somehow expecting existing files to be automatically copied to the remote server.

I don’t use it, so cannot help any more than that.

Oh, I see. Now this explains a lot. Thanks a lot for clearing that up.

Yes, but I was under the impression that this is a Gitlab thing, so I was searching for hits with Gitlab, not with VS Code…

Yes, exactly. I thought that I could create a file in the Web IDE (so that it lives in Gitlab) and then run it in the remote environment. And that when I connect to the remote environment, the file would be sent there.

Apparently, this is not how it works. But then I am afraid I fail to see the point of the integration with Gitlab at all…

Do I understand it now correctly that I have to create the file in the remote environment in order to be able to execute it there? And if so, what good is Gitlab for then (in this context)? Do I need to connect the remote environment back to Gitlab, in order manage my file in Gitlab?

(Full disclosure: I am a total Gitlab and VS Code noob)

VS Code connects to the remote environment, not Gitlab. Try following the steps in the DigitalOcean howto link that I provided. That document seems to show that it should work perfectly fine.

You should be using VS Code that is installed on your computer - not the VS Code web editor that is included in Gitlab.

I guess that makes sense. But that seems to be a totally different use case.

What is the point of connecting the remote environment to Gitlab (if you can’t remotely (build and) execute your code there)? I feel I am missing something.

You are not connecting Gitlab to the remote environment. I think you haven’t read up on this properly enough from all the links and search results I’ve provided. All of that is related to VS Code. Whether you use Gitlab or Github, or other Git servers is irrelevant. The remote connection is between VS Code and your remote server/machine.

Your code is commited to Gitlab/Github.
VS Code has access to what you cloned locally.
VS Code makes the remote connection to your server.
VS Code ensures the files are present on your remote environment.

Please read the DigitalOcean howto I linked, and all the Google results as well so that you understand how it’s working. The problem is your VS Code is not copying the files, the links I provided explain how you can do that.

I think this is just semantics. You are focusing on the fact that the Gitlab web ide is based on VS Code, whereas I am talking about Gitlab because it is the Gitlab web ide. But we are talking about the same thing (I think).

This is what doesn’t seem to be working for me.

Sorry for being obtuse but I don’t find anywhere where it demonstrates how a local file is pushed to the remote environment. The DigitalOcean howto says:

" To test out the ability to run remote code, create a new Python file called in your editor. When you are connected to your remote server, all files created through Visual Studio Code will be saved to that server, not on your local machine."

So (if I understand this correctly) you create the file already remotely. You don’t create it locally and then push it over to the remote environment. You create it there and it seems to live there.

I thought - and this apparently is wrong - that you could create a file locally (in my case in the Gitlab web ide) and then send it to the remote environment for compilation and execution.