Fapiko / intellij-better-direnv

Apache License 2.0
30 stars 18 forks source link

Latest release (1.0.0) breaks PyCharm run configuration #10

Closed amureki closed 1 year ago

amureki commented 2 years ago

Greetings dear fellows,

thanks for the plugin. I am using latest PyCharm 2022.2.2 and latest plugin (1.0.0) breaks run configuration for me. Instead of running tests or starting my dev server, it throws the next error:

class com.jetbrains.django.run.DjangoServerRunConfiguration cannot be cast to class com.jetbrains.python.run.PythonRunConfiguration (com.jetbrains.django.run.DjangoServerRunConfiguration and com.jetbrains.python.run.PythonRunConfiguration are in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @6e5fb29)

Small note - before that, version 0.3.0 was not throwing this error, however my direnv file was ignored (so the plugin was also not working).

Best, Rust

tejksat commented 2 years ago

I have been investigating the problem created in PyCharm issue tracker.

The problem seems to be in this line. PythonRunConfiguration class is not the base class for all "pythonic" run configurations. Django, Flask, pytest and other run configurations do not extend to this class. As you need here getCopyableUserData() method, I would use UserDataHolderBase class, which defines this method. As an alternative, you may also use AbstractPythonRunConfiguration for this purpose. And I suggest to check if pythonRunParams can be cast to any of these classes with instanceof prior of the casting.

jfreela commented 2 years ago

This should be resolved by https://github.com/Fapiko/intellij-better-direnv/pull/12

The cast has been changed from PythonRunConfiguration to AbstractPythonRunConfiguration<?> which all py based run configs seem to use

Fapiko commented 1 year ago

Merged that PR and pushed a build today - should be published to the marketplace in a day or two.

amureki commented 1 year ago

Merged that PR and pushed a build today - should be published to the marketplace in a day or two.

fantastic, thank you for the work! Will try it out later.

Cheers!

l0b0 commented 1 year ago

I think I'm experiencing the same issue with IDEA. I'm getting messages like this one:

Error running 'pytest all': class com.jetbrains.python.testing.PyTestConfiguration cannot be cast to class com.jetbrains.python.run.PythonRunConfiguration (com.jetbrains.python.testing.PyTestConfiguration and com.jetbrains.python.run.PythonRunConfiguration are in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @2e520029)

The latest version of this plugin for IntelliJ IDEA 2022.2.3 in IDEA is still 1.0.0 - does it need a separate release for IDEA, do I need a newer IDEA, or is something else going on?

PS: This thread and the associated issue both recommend uninstalling the plugin to fix the issue.

tojoc commented 11 months ago

I am getting the same issue in pycharm with the latest version (1.0.0) available for the plugin on PyCharm 2022.2.5 (Professional Edition)

class com.jetbrains.python.testing.pytestconfiguration cannot be cast to class com.jetbrains.python.run.pythonrunconfiguration (com.jetbrains.python.testing.pytestconfiguration and com.jetbrains.python.run.pythonrunconfiguration are in unnamed module of loader com.intellij.ide.plugins.cl.pluginclassloader @50f0f863)