Closed Silvio-Re closed 1 month ago
In the file /home/silvio/anaconda3/envs/spyder_env_3/lib/python3.10/site-packages/spyder/utils/environ.py
, coment out the section l.103 elif os.name == 'posix': ...
Spyder 6.0.0 starts as expected.
Hey @Silvio-Re, thanks for reporting. Could you post the contents of your ~/.bashrc
or ~/.zhrc
file so that we can try to reproduce this problem on our side?
Otherwise it won't be possible for us to fix it.
Hi @ccordoba12, thank you as well for maintaining this amazing tool.
Below is the content of the ~/.bashrc file. I have also attempted to start Spyder with an empty .bashrc, but the error persists.
Below is the content of the ~/.bashrc file.
Thanks for sharing your bashrc @Silvio-Re! I don't see anything suspicious in it.
I have also attempted to start Spyder with an empty .bashrc, but the error persists.
This is worrisome. Do you use zsh
by any chance?
This is worrisome. Do you use
zsh
by any chance?
No, zsh
is not installed on my system.
I tried:
elif os.name == 'posix':
try:
proc = run_shell_command('sleep 0.8', env={}, text=True)
print("start proc communicate")
stdout, stderr = proc.communicate(
timeout=3 if running_in_ci() else 0.5
)
print("end proc communicate")
print(stdout, stderr)
except Exception as exc:
print(exc)
logger.info(exc)
and the output is:
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
start proc communicate
Command 'sleep 0.8' timed out after 0.5 seconds
I'm not certain why this function is called six times at startup, but the timeout appears to function as intended with this simple command.
In fact it was simply that the run_shell_command was caled with
/home/silvio/.config/spyder-py3/user-env.sh
as cmdstr
argument.I belive the corect cmdstr
is ./home/silvio/.config/spyder-py3/user-env.sh
I think this does solve the issue.
Investingating further, there was two problems :
spyder &
to free the console. It appears to have the side effect of disrupting the behavior of proc.communicate
in get_user_environment_variables
and never return in certain conditions (it do return with sleep 8
but not always when executing user-env.sh
)spyder
keeping the console, proc.communicate
behave as expected and sometimes 0.5 s is too short to retrieve the env on my machine : Command '/home/silvio/.config/spyder-py3/user-env.sh' timed out after 0.5 seconds
, the main window appear but gets stuck like this :
If the timeout in increased to 1, spyder start as expected when launched with spyder
but not spyder &
where the problen is still the same, proc.communicate
never return ans the spashscreen gets stuck at Loading Code Analysis....
What is surprising is
spyder &
and spyder
wheras the env is obvously not retrived.proc.communicate
throw timeout, spyder fail to start.Thanks for the extra info @Silvio-Re! We'll try to address this in 6.0.1 because it's a very serious bug.
This is a result of #!/usr/local/bin/bash -i
in user-env.sh
. The interactive -i
does not seem to play nice with sending a parent process to the background (&
). I can reproduce this on macOS as well.
Ultimately, we should find a less hackish way to get current user environment variables on posix systems. 🤔
I can reproduce this on macOS as well.
What do you mean? Can you reproduce it with 6.0.0? Because this should be fixed in 6.0.1.
Ultimately, we should find a less hackish way to get current user environment variables on posix systems. 🤔
I don't think there is one (at least VSCode seems to be doing the same).
I can reproduce this on macOS as well.
What do you mean? Can you reproduce it with 6.0.0? Because this should be fixed in 6.0.1.
I mean that I can reproduce it on macOS without #22504. I just reverted that PR locally to see if I could reproduce it.
Ultimately, we should find a less hackish way to get current user environment variables on posix systems. 🤔
I don't think there is one (at least VSCode seems to be doing the same).
I don't know that there is one either; but it's good to know that we're in good company if VSCode is doing the same. Do you have a link to their implementation?
Do you have a link to their implementation?
Nop, but I saw that VSCode leaves an entry in the shell history when getting env vars (just as we did in one of our 6.0 alphas).
Nop, but I saw that VSCode leaves an entry in the shell history when getting env vars (just as we did in one of our 6.0 alphas).
Does that shell history entry reference a script that can be located and viewed? I'm just curious whether they are doing anything different (better?) than we are.
Does that shell history entry reference a script that can be located and viewed?
I think so. You need to install/start VSCode and then go to a terminal to inspect that command.
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)jupyter qtconsole
(if console-related)spyder --reset
Problem Description
6.0.0 not launching due to proc.communicate never timing out
What steps reproduce the problem?
I'm not sure why for my system (ubuntu VM)
stdout, stderr = proc.communicate(...
never returnWhat is the expected output? What do you see instead?
Spyder should launch
Versions