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

Error: Instalation script failed: sh: -c: line 0: syntax error near unexpected token (' sh: -c: line 0: "${SHELL}" #22843

Open
Papi77 opened this issue Nov 4, 2024 · 16 comments

Comments

@Papi77
Copy link

Papi77 commented Nov 4, 2024

Description

What steps will reproduce the problem?

Use latest version of Spyder 6.0.2, go to:
Tools > "Manage remote connections..." > enter SSH data and hit Connect.

Getting the following error:
Error: Instalation script failed: sh: -c: line 0: syntax error near unexpected token (' sh: -c: line 0: "${SHELL}"

Also, it is not possible to re-connect. Stop or Connect buttons are not active.

Versions

  • Spyder version: 6.0.2 (standalone)
  • Python version: 3.11.10 64-bit
  • Qt version: 5.15.8
  • PyQt5 version: 5.15.9
  • Operating System: Windows-10-10.0.22631-SP0

Dependencies

# Mandatory:
aiohttp >=3.9.3                  :  3.10.10 (OK)
asyncssh >=2.14.0,<3.0.0         :  2.18.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.1.0 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20241021 (OK)
github >=2.3.0                   :  2.4.0 (OK)
importlib_metadata >=4.6.0       :  8.5.0 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.29.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.1 (OK)
jellyfish >=0.7                  :  1.1.0 (OK)
jsonschema >=3.2.0               :  4.23.0 (OK)
keyring >=17.0.0                 :  25.5.0 (OK)
nbconvert >=4.0                  :  7.16.4 (OK)
numpydoc >=0.6.0                 :  1.8.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.4 (OK)
pexpect >=4.4.0                  :  4.9.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  6.1.0 (OK)
pygments >=2.0                   :  2.18.0 (OK)
pylint >=3.1,<4                  :  3.3.1 (OK)
pylint_venv >=3.0.2              :  3.0.4 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.12.0,<1.13.0           :  1.12.0 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
pyuca >=1.2                      :  1.2 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.3 (OK)
qtawesome >=1.3.1,<1.4.0         :  1.3.1 (OK)
qtconsole >=5.6.1,<5.7.0         :  5.6.1 (OK)
qtpy >=2.4.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.3.0 (OK)
setuptools >=49.6.0              :  75.3.0 (OK)
sphinx >=0.6.6                   :  8.1.3 (OK)
spyder_kernels >=3.0.1,<3.1.0    :  3.0.1 (OK)
superqt >=0.6.2,<1.0.0           :  0.6.7 (OK)
textdistance >=4.2.0             :  4.6.2 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  5.0.3 (OK)
yarl >=1.9.4                     :  1.16.0 (OK)
zmq >=24.0.0                     :  26.2.0 (OK)

# Optional:
cython >=0.21                    :  3.0.11 (OK)
matplotlib >=3.0.0               :  3.9.2 (OK)
numpy >=1.7                      :  2.1.2 (OK)
pandas >=1.1.1                   :  2.2.3 (OK)
scipy >=0.17.0                   :  1.14.1 (OK)
sympy >=0.7.3                    :  1.13.3 (OK)
@ccordoba12
Copy link
Member

Hey @Papi77, thanks for reporting. It seems you don't have curl installed in your server. Could you confirm if that's the case?

@ccordoba12
Copy link
Member

Another possible problem is that you're not using Bash as your default shell. So, please also let us know what shell you're using in your server.

@ccordoba12
Copy link
Member

@hlouzada, please take a look at this one. I think the problem is we're trying to run the installation script with the sh shell and not with Bash.

@hlouzada
Copy link
Contributor

hlouzada commented Nov 5, 2024

We don't require Bash, so it should work with either shell. But we do require curl.

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

Hi,
I am trying to reach a remote server which is a Synology DSM server.

  1. curl is already installed and available to the user:
    (python311_venv) (spyder) spyder@synek:/volume1/python311_venv$ curl --version
    curl 7.86.0 (x86_64-pc-linux-gnu) libcurl/7.86.0 OpenSSL/3.0.9 zlib/1.2.11 c-ares/1.14.0 nghttp2/1.41.0
    Release-Date: 2022-10-26
    Protocols: http https

  2. both bash and sh environments are availble (by default it's /bin/sh):
    echo $SHELL
    /bin/sh

I also tried to modify the user's default shell into bash:

(python311_venv) (spyder) spyder@synek:~$ cat .profile
SHELL=/bin/bash
exec bash
--> however that still doesn't work

  1. I was able to install micromamba manually which modified the .profile script to include the variables:
    (spyder) (spyder) spyder@synek:~$ env
    ...
    MAMBA_EXE=/volume1/homes/spyder/.local/bin/micromamba
    SHELL=/bin/bash
    MAMBA_ROOT_PREFIX=/volume1/homes/spyder/.local/share/mamba

--> however keep getting the same error

NOTE: What I am missing is the ability to add a default directory to which I will connect. Is it mandatory for it to be $HOME of the user?

@hlouzada
Copy link
Contributor

hlouzada commented Nov 6, 2024

Currently it's mandatory to use $HOME because the current user has permission to write in this location. You can export $HOME to where the micromamba and the environment can be installed. Also, the error log seems a bit strange too. Is the full error message Error: Instalation script failed: sh: -c: line 0: syntax error near unexpected token (' sh: -c: line 0: "${SHELL}"?

You can try manually installing the server, but it needs the $HOME set:
"${SHELL}" <(curl -L https://raw.githubusercontent.com/spyder-ide/spyder-remote-services/master/scripts/installer.sh)

@hlouzada
Copy link
Contributor

hlouzada commented Nov 6, 2024

@ccordoba12 What do you think about adding the possibility to change the default installation location in the future?

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

I have created a new "clean" user on my server and tried it again. The following is the error in Spyder log:

Info: Opening SSH connection — 22:29:06 06/11/2024 Info: SSH connection opened for None — 22:29:06 06/11/2024 Warning: spyder-remote-server is not installed: sh: //var/services/homes/testspyder/.local/bin/micromamba: No such file or directory — 22:29:06 06/11/2024 Info: Installing spyder-remote-server on 95.142.???.??? — 22:29:06 06/11/2024 Error: Instalation script failed: sh: -c: line 0: syntax error near unexpected token (' sh: -c: line 0: "${SHELL}"

Using putty, I have logged in and tried to execute the command manually:

testspyder@synek:~$ "${SHELL}" <(curl -L https://raw.githubusercontent.com/spyder-ide/spyder-remote-services/master/scripts/installer.sh)
-sh: syntax error near unexpected token `('
testspyder@synek:~$

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

However, after switching to bash, I was able to execute the command manually (which suggests that in fact bash is mandatory):

testspyder@synek:~$ bash
bash-4.4$ "${SHELL}" <(curl -L https://raw.githubusercontent.com/spyder-ide/spyder-remote-services/master/scripts/installer.sh)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3010  100  3010    0     0   7281      0 --:--:-- --:--:-- --:--:--  7270
warning  libmamba You have not set the root prefix environment variable.
    To permanently modify the root prefix location, either:
      - set the 'MAMBA_ROOT_PREFIX' environment variable
      - use the '-r,--root-prefix' CLI option
      - use 'micromamba shell init ...' to initialize your shell
        (then restart or source the contents of the shell init script)
    Continuing with default value: "/volume1/homes/testspyder/.local/share/mamba"
conda-forge/noarch                                  17.2MB @  21.4MB/s  0.7s
conda-forge/linux-64                                39.6MB @  18.7MB/s  2.0s


Transaction

  Prefix: /volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote

  Updating specs:

   - python=3.12
   - pip


  Package               Version  Build               Channel          Size
────────────────────────────────────────────────────────────────────────────
  Install:
────────────────────────────────────────────────────────────────────────────

  + _libgcc_mutex           0.1  conda_forge         conda-forge       3kB
  + _openmp_mutex           4.5  2_gnu               conda-forge      24kB
  + bzip2                 1.0.8  h4bc722e_7          conda-forge     253kB

...

Transaction finished

To activate this environment, use:

    micromamba activate spyder-remote

Or to execute a single command in this environment, use:

    micromamba run -n spyder-remote mycommand

warning  libmamba You have not set the root prefix environment variable.
    To permanently modify the root prefix location, either:
      - set the 'MAMBA_ROOT_PREFIX' environment variable
      - use the '-r,--root-prefix' CLI option
      - use 'micromamba shell init ...' to initialize your shell
        (then restart or source the contents of the shell init script)
    Continuing with default value: "/volume1/homes/testspyder/.local/share/mamba"
Collecting spyder-remote-services
  Downloading spyder_remote_services-0.1.3-py3-none-any.whl.metadata (1.8 kB)
Collecting jupyter-server<3.0,>=2.14.2 (from spyder-remote-services)
  Downloading jupyter_server-2.14.2-py3-none-any.whl.metadata (8.4 kB)

...
**Installed kernelspec spyder-kernel in /volume1/homes/testspyder/.local/share/jupyter/kernels/spyder-kernel**

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

Upon next attempt to connect from Spyder I'm now getting a different error:


Info: Opening SSH connection — 22:39:06 06/11/2024
Info: SSH connection opened for None — 22:39:07 06/11/2024
Info: spyder-remote-server is installed on 95.142.???.??? — 22:39:08 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:09 06/11/2024
Info: Starting remote server for 95.142.???.??? — 22:39:09 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:10 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:12 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:14 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:16 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:18 06/11/2024
Info: Error parsing server info, received: No info found. — 22:39:20 06/11/2024
Error: Faield to get server info — 22:39:20 06/11/2024

@hlouzada
Copy link
Contributor

hlouzada commented Nov 6, 2024

OK, thank you so much for your feedback. Will check on why bash is been required. Can you please try launching the server manually with /${HOME}/.local/bin/micromamba run -n spyder-remote spyder-server --jupyter-server? It seems that the server is also failing to launch for some reason.

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

testspyder@synek:~$ micromamba run -n spyder-remote spyder-server --jupyter-server
[I 2024-11-06 23:50:03.696 SpyderServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2024-11-06 23:50:03.721 SpyderServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2024-11-06 23:50:03.722 SpyderServerApp] Serving notebooks from local directory: /volume1/homes/testspyder
[I 2024-11-06 23:50:03.722 SpyderServerApp] Jupyter Server 2.14.2 is running at:
[I 2024-11-06 23:50:03.722 SpyderServerApp] http://localhost:34671/?token=d8d841e3655dc557097ff980d4201d51de0855b65cabbff3
[I 2024-11-06 23:50:03.722 SpyderServerApp]     http://127.0.0.1:34671/?token=d8d841e3655dc557097ff980d4201d51de0855b65cabbff3
[I 2024-11-06 23:50:03.722 SpyderServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Traceback (most recent call last):
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/bin/spyder-server", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/spyder_remote_services/__main__.py", line 15, in main
    launch_new_instance(rest)
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_core/application.py", line 283, in launch_instance
    super().launch_instance(argv=argv, **kwargs)
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_server/serverapp.py", line 3120, in start
    self.start_app()
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_server/serverapp.py", line 3021, in start_app
    self.write_server_info_file()
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_server/serverapp.py", line 2827, in write_server_info_file
    with secure_write(self.info_file) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_core/paths.py", line 1007, in secure_write
    raise RuntimeError(msg)
RuntimeError: Permissions assignment failed for secure file: '/volume1/homes/testspyder/.local/share/jupyter/runtime/jpserver-spyder.json'. Got '0o677' instead of '0o0600'.

@hlouzada
Copy link
Contributor

hlouzada commented Nov 6, 2024

Ohh it seems that your user directory permissions are messed up. For now please set JUPYTER_ALLOW_INSECURE_WRITES=true it should allow the jupter-server to start.

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

Hi,
I believe the issue is with file:
/volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_core/paths.py
line: 950

Looks like there is a typo:

        #stat.S_IMODE(Path(fname).stat().st_mode) & 0o6677
        stat.S_IMODE(Path(fname).stat().st_mode) & 0o600

--> After modifying the line I no longer have the error...

However, I'm not sure this is actually what I wanted :) What I was aiming for was to be able to open remote directories and maintain files, etc. Where can I see the remote files inside Spyder?

@Papi77
Copy link
Author

Papi77 commented Nov 6, 2024

Actually, now the connection says
Status: Active
The connection was established successfully.

However the Connection messages still show Info/Error:
Info: Opening SSH connection — 00:21:06 07/11/2024
Info: SSH connection opened for None — 00:21:07 07/11/2024
Info: spyder-remote-server is installed on 95.142.253.131 — 00:21:08 07/11/2024
Info: Error parsing server info, received: No info found. — 00:21:09 07/11/2024
Info: Starting remote server for 95.142.253.131 — 00:21:09 07/11/2024
Info: Remote server started for 95.142.253.131 at port 39870 — 00:21:10 07/11/2024
Info: Forwarding an free local port to remote port 39870 — 00:21:10 07/11/2024
Info: Forwarded local port 54488 to remote server at localhost:39870 — 00:21:10 07/11/2024

Also, does it mean I need to open 39870 on the server to access it?

@hlouzada
Copy link
Contributor

hlouzada commented Nov 6, 2024

Hi, I believe the issue is with file: /volume1/homes/testspyder/.local/share/mamba/envs/spyder-remote/lib/python3.12/site-packages/jupyter_core/paths.py line: 950

Looks like there is a typo:

        #stat.S_IMODE(Path(fname).stat().st_mode) & 0o6677
        stat.S_IMODE(Path(fname).stat().st_mode) & 0o600

--> After modifying the line I no longer have the error...

However, I'm not sure this is actually what I wanted :) What I was aiming for was to be able to open remote directories and maintain files, etc. Where can I see the remote files inside Spyder?

Strange, this seems to be an issue with jupyter. Will need to check up on that. Also, Spyder currently dosen't support opening remote directories or editing files remotely, but it's planned to be added in the next release. @ccordoba12

Actually, now the connection says Status: Active The connection was established successfully.

However the Connection messages still show Info/Error: Info: Opening SSH connection — 00:21:06 07/11/2024 Info: SSH connection opened for None — 00:21:07 07/11/2024 Info: spyder-remote-server is installed on 95.142.253.131 — 00:21:08 07/11/2024 Info: Error parsing server info, received: No info found. — 00:21:09 07/11/2024 Info: Starting remote server for 95.142.253.131 — 00:21:09 07/11/2024 Info: Remote server started for 95.142.253.131 at port 39870 — 00:21:10 07/11/2024 Info: Forwarding an free local port to remote port 39870 — 00:21:10 07/11/2024 Info: Forwarded local port 54488 to remote server at localhost:39870 — 00:21:10 07/11/2024

Also, does it mean I need to open 39870 on the server to access it?

No need to open/forward any port, as it is already tunneled by the current opened ssh connection. So you should be able to open any remote console/kernel now :)

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

No branches or pull requests

3 participants