Unable to run rails server with docker & wsl2

My operating system is Win11, I use docker and wsl2 at the same time, and the code is in the wsl system. When I run rails server I get a docker compose error:

invalid interpolation format for services.web.working_dir: "//wsl$/Ubuntu/data/code/xxx". You may need to escape any $ with another $

 

 

The problem is caused by the docker-compose.override.yml file, which has a line :

working_dir: "//wsl$/Ubuntu/data/code/xxx"

Is there something wrong with my configuration?

 

OS Version: WIN11 21H2 22000.795

WSL2 Version: Ubuntu 20.04.4 LTS

Docker Desktop Version:  4.10.1 (82475)

Rubymine Version: 2022.1.3

 

2

Hello! The problem seems related to this issue: RUBY-29812. Please upvote it and monitor it for updates. Would it be possible for testing purposes to move the project to Windows FS?

0

Thanks for the reply, I have solved this problem by adding project path mappings in server configuration, for example

//wsl$/Ubuntu/data/code/xxx=/xxx

And my previous project was in Windows FS, but it ran so slow that it affected the development work, and it was much better after moving to WSL FS.

0

Sorry for the offtopic, could you tell me more about your configuration. We would use this information to improve RubyMine. If I understand correctly, your project is in WSL2 FS. Where is your Ruby interpreter located? In docker-compose, WSL2 or on Windows host? What are you using docker-compose with WSL2 for?

Maybe you could share your project?

0

Because our project is not open source so I'm afraid I can't share it with you, but I can tell you some configuration information. Our development platform is Windows, we use WSL2 and Docker Desktop to run the project, the project is in WSL2 FS, and the Ruby interpreter is in a container run by docker compose. The reason why WSL2 is used is because the project runs very slowly in Windows FS, but it will be much faster in WSL2 FS, which is also officially recommended by Docker: https://docs.docker.com/desktop/windows/wsl/#best-practices

0

Thanks a lot for your answer!

0

FYI I was running into a similar issue with Docker+WSL2+Win11.
I am new to Docker so I am not sure if I did everything properly, but everything seem to work well if I open the project from the Windows file system or on a Mac (Ruby interpreter is docker-compose in both cases) but getting the "invalid interpolation format for services.web.working_dir" error if I don't add the path mapping in the Run/Debug configuration. If I add it, then I am running into a different error (missing gems, but thez are installed in the container). If I also add the path mapping under Rubz SDK and Gems then I am running into a third error:
rails  | /usr/local/bin/ruby: No such file or directory -- /app/bin/rails (LoadError)

Unfortunately, I can't resolve that last error (FYI the rails service is running without errors if I manually issue "docker compose up" from a WSL terminal).

I have zipped the .idea folder and the docker relevant files if it helps:
https://drive.google.com/file/d/1kQU5bKv72SviLtdwxqFNfiH2pX71q28g/view?usp=sharing

0

István Ujj-Meszaros, thank you for adding also a comment to the tracker's issue, I'll add here a link so that the other users can check it:

https://youtrack.jetbrains.com/issue/RUBY-29812/-No-SDK-shown-in-Project-settings-under-WSL2DockerDesktopproject-folder-in-WSL

But if your error differs, it'd be great if you could submit a separate issue so that they aren't mixed.

0

Hey Olga Kuvardina, my issue is probably the exact same issue, and it is now happening in every version of RubyMine that I could try (2022.3 EAP, 2022.2.2, 2022.2.3).
Here is the full output:

"C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe" -f \\wsl$\Ubuntu-22.04\home\styu0\RubyMineProjects\projectname\docker-compose.yml -f C:\Users\styu0\AppData\Local\JetBrains\RubyMine2022.2\tmp\docker-compose.override.35.yml up --exit-code-from rails --abort-on-container-exit rails
invalid interpolation format for services.rails.working_dir.
You may need to escape any $ with another $.
//wsl$/Ubuntu-22.04/home/styu0/RubyMineProjects/projectname

Process finished with exit code 15

Please handle this as very high priority as this error makes WSL2 projects with docker compose to unable to work with, and the fix is probably just to escape the $ character (but it has to be done by the IDE). I have tried to map the path to a drive letter but it seems that a WSL path can't be mapped, unfortunately.

0

István Ujj-Meszaros just to be sure, have you tried working with Rails with docker-compose SDK when the project resides inside Windows FS?

1

Yes, the same project is working from the Windows FS, but it is running extremely slow, and also there is an issue with webpack-dev-server, it doesn't get notified about the file changes, so it doesn't recompile the scss files on changes.

0

At the moment there might be problems with how projects located inside WSL2 work, we have a corresponding issue for that:

https://youtrack.jetbrains.com/issue/RUBY-25956/WSL2-ability-to-select-wsl2-host-for-project-location

0

FYI I have spent the last two days (~20 hours) with trial and error, and everything seems to work as expected now when using docker compose, and the project files hosted under WSL2. What I had to do is I had to remove my path mapping from under "Ruby SDK and Gems" and had to add the path mapping under the Run configuration. If it was defined at both places then I got an error when composer tried to start the rails server, with the below error:


Container rails  Recreated
Attaching to rails
rails  | Traceback (most recent call last):
rails  | /usr/local/bin/ruby: No such file or directory -- /app/bin/bundle (LoadError)
rails exited with code 1
Aborting on container exit...
Container rails  Stopping

So, the path mapping mustn't be defined for the SDK, and must be defined for the run configuration (FYI there is no browse... functionality at the Run configuration path mapping, which also is a minor bug - I had to paste the full wsl$ path there, while the SDK path mapping configurator has a browser icon which defaults to the correct wsl$ path).

If there is no path mapping at all (both the SDK path mappings and the Run configuration path mapping are empty) then the below error is happening:

"C:\Program Files\Docker\Docker\resources\bin\docker.exe" compose -f \\wsl$\Ubuntu-22.04\home\styu0\RubyMineProjects\projectname\docker-compose.yml -f C:\Users\styu0\AppData\Local\JetBrains\RubyMine2022.3\tmp\docker-compose.override.548.yml up --exit-code-from rails --abort-on-container-exit rails
invalid interpolation format for services.rails.working_dir.
You may need to escape any $ with another $.
//wsl$/Ubuntu-22.04/home/styu0/RubyMineProjects/projectname

Process finished with exit code 15

I hope it helps.

2

István Ujj-Meszaros I tried your solution and it didn't work, could you please share screenshots for your solution?

Thanks!

0

请先登录再写评论。