Run/debug after renaming a file

Answered

What I'm seeing:

I renamed a python file in PyCharm using the Refactor > Rename command (Community Edition 2018.2 on Mac OS X 10.13 High Sierra). Now, when I try to run/debug from the IDE the list of files to choose from is still showing the previous file name rather than the new name. Selecting the old file name actually runs the correct (renamed) file, so it's not preventing me from doing anything. Just a little confusing.

What I've done:

I've closed/reopened PyCharm and closed/reopened the project folder.

My question(s):

Is this a known problem? Can anyone try it out and see if you can reproduce it? Do I need to provide any more information to help troubleshoot this?

13 comments

I found out where to fix this. It's in the run/debug configuration settings. You have to select the option to "Edit Configurations..." settings. In that window you can change the name of the run/debug configuration.

1

Thank you for finding this. If you ask me, it's a bug that this does not happen automatically when renaming a file using the IDE's own rename option on the file in question.

1

@kmyerscough, you won't get an argument from me. It was really confusing to run something that looked like it was going to run the old file (somehow, magically). So yeah, +1 for a bug report.

0

Hi,

Thank you for contacting PyCharm support and sorry for a super-late reply.

Could you please provide a screenshot demonstrating the problem and also a screenshot of `PyCharm | About PyCharm` window?

Looking forward to your reply.

Kind regards,

Sergey

https://www.jetbrains.com

The Drive to Develop

0

You were probably addressing the OP, but for me it looks like below.

Hope this helps.

Keith

0

Hahaha! I notice now that the refactor did change the value of 'test.py' inside the triple-quoted string into 'new_name.py', leaving a rather confusing message, sorry about that.

0

Here's a screenshot of the behavior that I'm seeing.


And here's the "About" window.

0

Oops. Guess my image editing skills are leaving a little to be desired today. Let me know if you need any clarification of what I tried to show with the workspace image.

0

Thank you for getting back to me Earl.

Oh, I see. This isn't a bug. You are changing the name of the file, but there is also the name of Run/Debug Configuration.

When you create a run configuration it is by default places the name of the file, but it can be different if you change it.

But maybe PyCharm really should prompt you with some message.

Please feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY and please let us know if you need any help.

Kind regards,

Sergey

https://www.jetbrains.com

The Drive to Develop

0

@Sergey, I had a good laugh at your response. I've always heard the quip "it's a feature, not a bug" and now I've got a real world experience with it. :)

Yes, at the very least the prompt that comes up when you rename/refactor should include some sort of action/option to change the name of the configuration for run/debug.There is already a confirmation popup with two options on it. You may as well add another one to warn/ask about renaming the configuration. Since run/debug operates at the file level (you can run/debug and individual file in the project) then it would be nice to be able to keep that configuration name in sync with the filename.

When I submit this enhancement request is there some way to reference this forum support post?

Earl

0

I understand the file name and the configuration name being inherently different objects, but if the one is named after the other by default, why not change the the one along with the other by default. Use cases where the configuration name is different from the filename must be rare, and easily caught by not renaming the configuration if the name is already different from the filename.

The first time I really suffered from this was when I realized that my first file wasn't really doing what I had named it for, renamed it and then made a second file with the same name as the first originally had. This gave the rather ugly Windows-like ;-) "first_filename.py (1)" as config name...

0

>When I submit this enhancement request is there some way to reference this forum support post?

Yes, just put the link in the comment.

Kind regards,

Sergey

https://www.jetbrains.com

The Drive to Develop

0

Hi Earl,

I already did so, based on this comment, see https://intellij-support.jetbrains.com/hc/en-us/requests/1772188.

However, there Sergey points out that it is a known issue, see https://youtrack.jetbrains.com/issue/PY-31964.

Have a nice day!

Keith

P.S. I now see the issue is one raised by you, Earl. I'm a bit confused, but I think everything is right now.

0

Please sign in to leave a comment.