Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reopen last project command line option conflicts with the new connect to kernel one #23497

Open
Social-Mean opened this issue Jan 17, 2025 · 1 comment · May be fixed by #23498
Open

Reopen last project command line option conflicts with the new connect to kernel one #23497

Social-Mean opened this issue Jan 17, 2025 · 1 comment · May be fixed by #23498

Comments

@Social-Mean
Copy link
Contributor

Hi @ccordoba12 , I finally find the reason why I cannot connect to existing kernel in #23444.
Briefly, the function of the project plugin to open the previous project conflicts with the function of ipythonconsole plugin to connect to the kernel.


In #23444 (comment), I described the process of failing to connect to the kernel. But it's not detailed.

Detailed process

  1. Following the dev guide to config the spyder-dev conda environment.
  2. Start Spyder from source.
    python bootstrap.py
    
  3. Open a project (through menu bar).
  4. Close Spyder.
  5. Start Spyder with --connect-to-kernel kernel-*.json option.
    (spyder-dev) $ python bootstrap.py -- --connect-to-kernel=kernel-12345.json
    

The result: Spyder connects to kernel-12345 indeed. But then Spyder window flashes and a new kernel is created.

Reason

Spyder will reopen last project when start.

def on_mainwindow_visible(self):
# Open project passed on the command line or reopen last one.
cli_options = self.get_command_line_options()
initial_cwd = self._main.get_initial_working_directory()
if cli_options.project is not None:
logger.debug('Opening project from the command line')
project = osp.normpath(
osp.join(initial_cwd, cli_options.project)
)
self.open_project(
project,
workdir=cli_options.working_directory
)
else:
self.get_widget().set_pane_empty()
logger.debug('Reopening project from last session')
self.get_widget().reopen_last_project()

The method reopen_last_project will flash Spyder.

Fix

I have fixed this bug on my computer. I will open a pull request later.

Social-Mean added a commit to Social-Mean/spyder that referenced this issue Jan 17, 2025
@Social-Mean Social-Mean linked a pull request Jan 17, 2025 that will close this issue
3 tasks
@ccordoba12 ccordoba12 changed the title [BUG] Reopen Last Project Conflicts with Connecting to Kernel Reopen last project command line option conflicts with the new connect to kernel one Jan 17, 2025
@ccordoba12 ccordoba12 added this to the v6.0.4 milestone Jan 17, 2025
@ccordoba12
Copy link
Member

Ok, thanks for finding the problem and proposing a solution @Social-Mean!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants