Some time ago, I finally managed to switch from Visual Studio to JetBrains Rider at work. Finally, because I used to work a lot with Rider before, and I really like this IDE. Unfortunately, I ran into some annoying problems with docker-compose debug configuration.

It turns out that the same problem also affects users of other InteliJ-based IDEs like RubyMine, PyCharm, PhpStorm and GoLand. Fortunately, I was able to fix it.

Debugging docker-compose service and UnicodeDecodeError

Rider solves the topic of Run/Debug configuration differently from Visual Studio, so I had to add my configuration myself. It is not that hard. All you need to do is select the docker-compose file, select the service to which the debugger is to attach, and that’s it.

What was my surprise when after clicking the Debug button I saw the following error:

Deploying 'Compose: local'...
docker-compose -f C:\Repositories\TestProject\docker-compose.yml -f C:\Users\Mikołaj\AppData\Local\JetBrains\Rider2021.2\tmp\docker-compose.override.yml up --no-deps --build my_service
ERROR: .UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 536: invalid start byte

Have I made any mistake? I tried clicking the Run button. The application started without any problem. WTF?!

Mikołaj is a name of doom

I decided to check the difference between the Rider launch process in Debug and Release mode. It turned out that in the case of the Debug mode, it generates a docker-compose file with which it overwrites the original file. I was convinced that my original docker-compose was correct. Was the error related to the generated file? Let’s see what it looks like. My temporary file was stored in the following location: %LocalAppData%\JetBrains\Rider2021.2\tmp\docker-compose.override.yml

version: "3.4"
services:
  my_service:
    entrypoint:
    - "/riderDebugger/runtime-dotnet.sh"
    - "/riderDebugger/JetBrains.Debugger.Worker.exe"
    - "--mode=server"
    - "--frontend-port=57001"
    - "--backend-port=57101"
    environment:
      RIDER_DEBUGGER_LOG_DIR: "/riderLogs"
      RESHARPER_LOG_CONF: "/riderLogsConf/backend-log.xml"
    ports:
    - "57001:57001"
    - "57101:57101"
    volumes:
    - "C:\\Program Files (x86)\\JetBrains\\JetBrains Rider 2021.1.1\\lib\\ReSharperHost:/riderDebugger"
    - "C:\\Users\\Miko�aj\\AppData\\Local\\JetBrains\\Rider2021.2\\log\\DebuggerWorker\\\
      JetBrains.Debugger.Worker.2021_10_17_20_32_30:/riderLogs:rw"
    - "C:\\Program Files (x86)\\JetBrains\\JetBrains Rider 2021.1.1/bin:/riderLogsConf"

Take a look at the volumes section. One of the entries contains some strange character.

- "C:\\Users\\Miko�aj\\AppData\\Local\\JetBrains\\Rider2021.2\\log\\DebuggerWorker\\\
      JetBrains.Debugger.Worker.2021_10_17_20_32_30:/riderLogs:rw"

My username contains a "ł" character and because of it, this file cannot be processed properly.

But what can I do about it? After all, this file is generated automatically by Rider.

Let’s face the problem

When I found out that the bug was in the Rider itself, I reported it to technical support. I also found a similar report for PyCharm. Unfortunately, things haven’t moved forward since then. I decided to try to solve this problem myself. Fortunately, I was able to do this and can share my solution to this very annoying problem with others.

The first idea was to change the username to one that does not contain Polish characters. It turned out that Windows does not rename the user’s folder when changing the username. Manually renaming the folder was not an option. This way I could corrupt my profile in the system.

What if I changed the path where Rider stores temporary files? I started browsing the documentation from JetBrains and found an interesting article on advanced configuration of InteliJ-based IDEs. This article explains how you can change the paths that the IDE uses.

Solution

Start your IDE, and go to the Help section in the main menu. There you will find the Edit Custom Properties option. Click on it. The %APPDATA%\JetBrains\{your_IDE_version}\idea.properties file will open for editing.

Add the following line to it:

idea.system.path=${root.dir}/JetBrains/Rider/system

Save the file and restart the IDE. From now on, Rider will keep temporary files in C:\JetBrains\Rider\system directory. Of course you may have a different drive under the variable ${root.dir}, but the idea is the same.

Finally, you have to clean up after yourself. Go to the Help section of the main menu and click Delete Leftover IDE Directories.... Rider will scan for unnecessary folders and offer to delete them.

That’s all! Finally, you can start debugging your services launched from docker-compose!

Summary

From the moment the bug was reported to JetBrains support, 7 months passed until the publication of this post. I don’t know if they will ever fix this bug, but all I know is that it prevented me from working in my favorite IDE.

I hope you found this article helpful. If you have any questions about this, feel free to contact me.