Pycharm does not update sceleton on python connected with wsl-2

Hello

I am trying to switch already prepared Django project to WSL remote python on Ubuntu.

I have created virtual enviroment, installed all packages there via PIPENV and pointed Pycharm to python executable file in this venv on wsl2.

All works except that skeleton update can't be launched as it describet in the traceback below.

 

Is it anything can be done to fix it?

I have tried invalidate cache/restart already.

All imports are marked with red lines but they are work fine. Seems like Pycharm can't follow path correctly...


failed to run generator3/__main__.py for wsl://UBUNTU/home/hardcase/.local/share/virtualenvs/ubuntu-test-1sQFdO7M/bin/python3.8, exit code 1, stderr: ----- Failed to process '_abc' while nothing yet: [Errno 1] Operation not permitted: '/mnt/c/Users/hardcase1/AppData/Local/JetBrains/PyCharm2020.1/python_stubs/688584981/array.py' Traceback (most recent call last): File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/__main__.py", line 167, in main() File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/__main__.py", line 140, in main generator.discover_and_process_all_modules(name_pattern=args.name_pattern, builtins_only=args.builtins_only) File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/core.py", line 442, in discover_and_process_all_modules self.process_module(mod.qname, mod.path) File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/core.py", line 516, in process_module status = self.reuse_or_generate_skeleton(mod_name, mod_path, sdk_skeleton_state) File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/core.py", line 574, in reuse_or_generate_skeleton copy_skeletons(mod_cache_dir, self.output_dir, get_module_origin(mod_path, mod_name)) File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/util_methods.py", line 780, in copy_skeletons copy(src_dir, dst_dir, merge=True, File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/util_methods.py", line 725, in copy copy(child_src, child_dst, merge=merge, File "/mnt/c/Program Files/JetBrains/PyCharm 2020.1/plugins/python/helpers/generator3/util_methods.py", line 736, in copy shutil.copy(src, dst) File "/usr/lib/python3.8/shutil.py", line 416, in copy copymode(src, dst, follow_symlinks=follow_symlinks) File "/usr/lib/python3.8/shutil.py", line 305, in copymode chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: [Errno 1] Operation not permitted: '/mnt/c/Users/hardcase1/AppData/Local/JetBrains/PyCharm2020.1/python_stubs/688584981/array.py' -----

12 comments
Comment actions Permalink

Hi,

How did you open the project? Using local c:\ path or //wsl$ path? Actually I tried both ways but couldn't reproduce the issue.

Could you try recreating the interpreter, but do not add the interpreter paths manually? PyCharm should populate interpreter paths automatically - does it work?

0
Comment actions Permalink

Thank you for the answer. It has 'magically' fixed itself after couple of days.

0
Comment actions Permalink

I have the same issue but can't fix it.

Tried reinstalling both ubuntu and Pycharm professional 2020.

Tried restarting.

Recreated the interpreter several times.

It works by rolling back to Pycharm professional 2019.3.5 - not a fix, cause the new version is not working properly.

0
Comment actions Permalink

I am also using wsl2 and PyCharm and I have a very similar issue/error message:

failed to run generator3/__main__.py for wsl://UBUNTU2004/home/.../conda/envs/.../bin/python, exit code 1, stderr: ----- Failed to process '_ast' while nothing yet: [Errno 1] Operation not permitted:

"/home/..../conda/envs/..../lib/python3.8/shutil.py", line 305, in copymode chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: [Errno 1] Operation not permitted: '/mnt/c/Users/...../AppData/Local/JetBrains/PyCharm2020.2/python_stubs/-848334156/atexit.py' -----

Sometimes this error raises or the one, the topic opener posted. It seams both are raised due to permission errors.

 

 

PyCharm 2020.2.3 (Professional Edition)
Build #PY-202.7660.27, built on October 6, 2020
Licensed to
Subscription is active until
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Non-Bundled Plugins: com.jetbrains.intellij.datalore

0
Comment actions Permalink

same problem for me - need urgent help!

0
Comment actions Permalink

Alexander Ostrikov what PyCharm version do you use?
If it's the latest one (2020.3.2 at the moment), please file an issue to https://youtrack.jetbrains.com/issues/PY and attach your idea.log file from Help | Show Log in...

0
Comment actions Permalink

Same here - is there any solution yet?

0
Comment actions Permalink

Hello @Marius Garbowski!

Regrettably, no details were provided for further investigation. Could you please file an issue to https://youtrack.jetbrains.com/issues/PY and attach your idea.log file from Help | Show Log in...

0
Comment actions Permalink

I have a workaround for not being able to update skeletons on venv WSL2 interpreters. It's a permissions problem due to the default way that WSL2 mounts the C drive. It doesn't try to map file permissions properly, instead making everything owned by `root`. This is fixable, but has a big caveat - your username in your WSL2 distro **must** match your Windows username. Here are the steps:

In your WSL distro, edit `/etc/wsl.conf` with `sudo vim /etc/wsl.conf`.

You'll have a section at the top that looks like this:

```
[automount]
enabled = true
mountfstab = true
root = /mnt/
options =
```

Simply add `"metadata"` to the end of the `options` line so it looks like this:

```
[automount]
enabled = true
mountfstab = true
root = /mnt/
options = "metadata"
```

From here, exit PyCharm, exit your WSL shell(s) and run this in an administrator `cmd`/`powershell` session: `wsl --shutdown`.

Once that completes, start up your WSL shell and PyCharm again, problem should be fixed.

7
Comment actions Permalink

Matt Waters Brilliant, worked for me!

1
Comment actions Permalink

Thanks Matt Waters, this worked and saved my day!

0
Comment actions Permalink

If you're lost soul from 2022 and probably later here is how I made it work:

  1. Uninstalled old Ubuntu
  2. Installed Ubuntu 22.04 LTS
  3. Created an account with the same name as my user's folder name in C:\Users

For me /etc/wsl.conf was empty and I did not change it. I do not know if all steps are necessary to make it work, but for me they were sufficient.

0

Please sign in to leave a comment.