GitHub Copilot in JetBrains IDEs in the Russian Federation

GitHub Copilot in JetBrains IDEs in the Russian Federation

GitHub Copilot in JetBrains IDEs in the Russian Federation

▸ Introduction

In 2022, GitHub Copilot was released to the public, a fairly convenient modern tool for developers that uses generative language models and code from GitHub public repositories. It cannot be said that many people accepted this development with open arms, but it is still a great contribution to the development of tools for programmers and more. I know that companies prohibit the use of any AI tools for writing code, but at home, for personal projects, freelancing, Copilot is an essential tool.

Various integrations with Copilot will also be released in 2023. Soon after this, its use in the Russian Federation and a number of other countries was limited (like many other services). Experienced PC users didn't find these limitations a problem, but I was surprised to learn that some of my friends still didn't know how to use such a powerful tool.

In this short article I will share my experience of interacting with GitHub Copilot, and most importantly, how to use it in the IDE from JetBrains. Enjoy reading!

▸ Getting GitHub Copilot

I won’t take bread from my colleagues, so you can read about ways to (free) get Copilot on the Internet, that’s not what the article is about. Let me just say that I gained access using GitHub Student Pack, there are many guides on how to do this. Please note that you need to complete the certificate correctly before submitting it to GitHub.

You can read more about how to do this here.

Of course, you can also try paying for the subscription yourself. The method above is only relevant for schoolchildren and students, because you need a certificate from the university/school. (It’s very difficult to do it yourself…)

▸ Download and configure Tor

Beginning of work

To bypass the blocking we will use Tor. We only need the CLI version, so we don't have to install a browser.

You can get CLI Tor in 2 ways:

  • Find and install using your package manager (for MacOS this is brew)

  • Download TorBrowser and find the executable Tor in the program files. On Windows you can find it under Tor Browser ▸ Browser ▸ TorBrowser ▸ Tor

For Windows

If you are on Windows, you can collect all the files yourself: obfs4proxy, geoip and others. Or take a ready-made package from me. In general, they are all in the TorBrowser files, but I had problems with obfs4proxy. I have already collected everything in one folder. You need to unzip and place the Tor folder in Program Files.

How to set it up?

1. We get bridges

  1. On the site select obsf4 https://bridges.torproject.org/options/

  2. We pass the captcha

  3. Copying bridges (there are two of them)

2. Insert into torrc

The torrc file is a configuration file.

On Windows:

C ▸ Program Files ▸ Tor ▸ torrc

Write to file my template.

On MacOS (Linux):

usr ▸ local ▸ etc ▸ tor ▸ torrc

Write to file my template.

We also insert our bridge lines into this file.

3. Autostart

On Windows:

We create a service with the commands:

"C:\Program Files\Tor\tor\tor.exe" —nt-service "-f" "C:\Program Files\Tor\torrc"

In the task manager, you can find out the status of the service and enable automatic startup when the system starts.

On MacOS:

Team:

brew install tor

In the settings, go to Settings ▸ General ▸ Login Objects and enable tor.

What can you customize?

In field HTTPTunnelPort you can specify the port where the Socks5 ▸ HTTP tunnel will be created. It will need to be remembered. You need to use HTTP, since Copilot does not work on Socks.

▸ Connect to IDE

1. Proxy configuration

In any JetBrains IDE, go to the settings and look for the Proxy item. Set the settings as in the screenshot.

Proxy settings

Proxy settings

Host name – only 127.0.0.1 (localhost does not work)

No proxy – not necessary.

Port number – your port from the previous paragraph.

2. Download the Copilot plugin.

It won't work yet.

3. Save, restart.

Log in to your Copilot account and rejoice.

Important improvements for Android Studio

▸ Important improvements for Android Studio

If you're working in Android Studio, then you're probably using Gradle. Each time it starts, Studio will ask you to add a proxy configuration for the Gradle daemon.

You need to find your gradle.properties (Global) system Gradle file (namely global). It will be at the bottom of the list of project files if you choose to display the project as Android.

There you need to add the following lines:

systemProp.http.nonProxyHosts=dl.google.com|repo.maven.apache.org
systemProp.https.nonProxyHosts=dl.google.com|repo.maven.apache.org
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=<ВАШ ПОРТ>
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=<ВАШ ПОРТ>

We do this so as not to proxy the project dependency download traffic; some of the hosts are not working and Gradle cannot find a resource to download. Don't forget to restart the program after changing proxy settings.

▸ Conclusion

I have provided detailed instructions for setting up Copilot. This solution has been working for me for over a year on a Mac and a Windows laptop. The advantages of this approach include the fact that we do not need to route all device traffic through a VPN or Proxy; it is completely free, fast and easy to configure.

I'm not a fan of writing code blindly, and I don't use Copilot to develop complex parts of a project. But it is an indispensable tool for creating tests, mock data, models and other routine tasks. Use it wisely!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *