DEV Community

Cover image for Fixing Pycharm remote Interpreter with Vagrant and macOS Catalina
Alex V
Alex V

Posted on

Fixing Pycharm remote Interpreter with Vagrant and macOS Catalina

Fookin Apple

Mac os Catalia was released on October 2019 (last decade!) and it introduced a bunch of security fixes.

Full disk access was introduced as a permission that you need to allow tools to access folders in your /Users directory.

This broke a lot of things, just google "full disk access" and you see pages on top of pages of articles all explaining how to add something to the Full Disk Access.

Our issue

In our case, vagrant NFS mounts stopped working. And we can't run our Vagrant without those mounts.

We've added a temp. fix, and Vagrant 2.6 actually released a fix of their own, which adds the exported paths in the longer form, which doesn't need full disk access to work,
Old form : /Users/username/folder
Longer form: /System/Volumes/Data/Users/username/folder

So now that that's fixed, our vagrant is happy and boots fine and everything is ok.

(There's another fix, adding /sbin/nfsd to Full Disk Access permissions which kinda works as well)

PyCharm issues

We then had a different issue, where in devs who updated to Catalina, ran their pyCharm and set up a remote interpreter, suddenly couldn't run their debug configurations through pyCharm anymore.

It showed the following error:

ssh://vagrant@127.0.0.1:2222/folder/bin/python -u /Users/usernname/folder/utils/run_something.py
zsh:cd:1: no such file or directory: /Users/username/folder/utils
/folder/remove_venv/bin/python: can't open file 'Users/usernname/folder/utils/run_something.py': [Errno 2] No such file or directory
Enter fullscreen mode Exit fullscreen mode

Basically PyCharm was complaining that it can't create a path mapping between a mac folder to a mounted vagrant NFS folder.

This is due to this magical thing that pyCharm does when you create a python remote interpreter (I assume the same is true for other languages and Jetbrain IDEs as well)
It reads your vagrant file, and tries to extract the paths you are about to mount inside your vagrant.

The problem though, is pyCharm doesn't know about this Catalina long form /Systems/Volume... path, and the fact that Vagrant kinda hacks it together, so the path mappings don't work

Solution

Until jetBrains learn to deal with this problem (track the issue here, vote on it, make some noise if you have this)
We are forces with this solution:

Add a path mapping in your debug configuration to the mounted NFS folder inside vagrant manually.

Make it a little bit better

If you are used to have a lot of debug configurations, let's say you create one for each unit test you have, you can edit the template for the debug configuration and add the path mapping there, it will then exist for all new configurations created from that template.

Just expand the template cogwheel and edit the template of the config

Top comments (0)