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

automatic update process broken under windows 11 #163

Closed
JHenneberg opened this issue Jul 5, 2022 · 8 comments · Fixed by #164
Closed

automatic update process broken under windows 11 #163

JHenneberg opened this issue Jul 5, 2022 · 8 comments · Fixed by #164
Labels
bug Something isn't working

Comments

@JHenneberg
Copy link

Describe the bug
Once a new version is released and due to a start of VSCode an update is triggered, the installation fails.

To Reproduce

  1. Install older version of current one.

  2. Start VSCode to trigger automatic update process
    image

  3. Restart VSCode
    image

  4. Check c:\Users\<USER>\AppData\Local\Programs\Python\Python310\Lib\site-packages\ folder: There are now two folders named:
    ~ortls-2.10.0.dist-info and ~ortls . There is no fortls folder

By executing pip install fortls the installation of the current version is performed correclty. Just the leftover folder are still there and have to be deinstalled manually.

When still on 2.10 and pip install fortls --upgrade is exectued manually there are no ghostfolders and the 2.11 is installed.

Expected behavior
Normal update process

Setup information (please complete the following information):

  • OS: Windows 11
  • Python Version: 3.10
  • fortls Version 2.10/2.11
  • Code editor used: VSCode
@JHenneberg JHenneberg added the bug Something isn't working label Jul 5, 2022
@gnikit
Copy link
Member

gnikit commented Jul 5, 2022

I don't think the automatic update process is broken since there is a unit which still passes on Windows.

From the looks of it there is something else wrong, most likely your options, which causes this.

Can you post the channel logs from vscode along with your Fortran settings.

@JHenneberg
Copy link
Author

JHenneberg commented Jul 5, 2022

The error msg is indicating that smth is wrong with the settings, but installing the newest version like I mentioned or updating manually works fine. The message is not appearing.
The only setting that I have for fortls is "fortran.fortls.notifyInit": true,

further options concerning fortran:

"fortran.preferredCase": "lowercase",
    "[FortranFixedForm]": {
        "editor.rulers": [
            {
                "column": 72,
                "color": "#E06C75"
            },
            {
                "column": 6,
                "color": "#E06C75"
            }
        ]
    },

Log:

["INFO" - 10:04:15] Fortran Language Server
["INFO" - 10:04:15] Initialising Language Server for workspace: d:\Gitea\xxx\file.f90 with command-line options: --enable_code_actions, --hover_signature, --use_signature_help, --lowercase_intrinsics, --nthreads=4, --notify_init, --incremental_sync
[INFO - 10:04:16] A newer version of fortls is available for download
[INFO - 10:04:16] Downloading from PyPi fortls 2.11.0
[INFO - 10:04:18] Requirement already satisfied: fortls in c:\users\henneberg\appdata\local\programs\python\python310\lib\site-packages (2.10.0)

Collecting fortls

  Using cached fortls-2.11.0-py3-none-any.whl (92 kB)

Requirement already satisfied: packaging in c:\users\henneberg\appdata\local\programs\python\python310\lib\site-packages (from fortls) (21.3)

Requirement already satisfied: json5 in c:\users\henneberg\appdata\local\programs\python\python310\lib\site-packages (from fortls) (0.9.8)

Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\users\henneberg\appdata\local\programs\python\python310\lib\site-packages (from packaging->fortls) (3.0.9)

Installing collected packages: fortls

  Attempting uninstall: fortls

    Found existing installation: fortls 2.10.0

    Uninstalling fortls-2.10.0:


[ERRO - 10:04:18] ERROR: Could not install packages due to an OSError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\henneberg\\appdata\\local\\programs\\python\\python310\\scripts\\fortls.exe'

Consider using the `--user` option or check the permissions.
[INFO - 10:04:18] Please restart the server for the new version to activate
Process SpawnPoolWorker-1:
Traceback (most recent call last):
  File "C:\Users\Henneberg\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "C:\Users\Henneberg\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Henneberg\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 114, in worker
    task = get()
  File "C:\Users\Henneberg\AppData\Local\Programs\Python\Python310\lib\multiprocessing\queues.py", line 368, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'fortls'

I tried again because of the err msg indicated that there might be a fortls version already running so I made sure no fortls was running in the taks manager and retried but the same error appears.

This is not happening since 2.11.0. Its already like this for a couple of version and on my working and private machine. I can try tomorrow on a collouegues machine because both of my machines are probably setup in a very similar way.

Not sure if --user is the solution because installing it myself via commandline is working fine without being in admin mode.

@gnikit
Copy link
Member

gnikit commented Jul 5, 2022

I think there is something funny going on with Windows 11 and the file permissions. My uneducated guess is that Windows puts a lock on folders that have running processes thus not allowing VS Code spawned pip to run and update like it is supposed to.

I don't think it's pip itself, I gave it a go on Linux but you can try it yourself on Windows.

  • Add the --disable_autoupdate flag to fortls so as to not update upon initialisation.
  • Open a Fortran project for fortls to spawn and initialise
  • Open a terminal and run python -m pip install --user --upgrade fortls -y (python being the location of your Python dist)

That should run to completion and when restarting fortls via the command palette Fortran: Restart the Fortran Language Server the log channel should report the new version.

As a last effort you can attempt to upgrade your pip installation

python -m pip install --upgrade pip

If it is Windows itself (or anything else that is close to OS level) it won't be possible to fix, since it would require fortls to interact with the underlying OS in ways that are "unacceptable" for a lot of the users, change file permissions, stop and restart tasks, etc.

@gnikit
Copy link
Member

gnikit commented Jul 5, 2022

Not sure if --user is the solution because installing it myself via commandline is working fine without being in admin mode.

--user is used for portability. In older versions of pip attempting to install packages in a places where you don't have permissions would fail, newer versions of pip will retry to install with the --user flag.

@JHenneberg
Copy link
Author

JHenneberg commented Jul 5, 2022

despite -y is not recognized it works (python -m pip install --user --upgrade fortls). I retested against python -m pip install fortls --upgrade which fails.

@gnikit
Copy link
Member

gnikit commented Jul 5, 2022

Apologies, the -y was a mistake.

The --user results make sense, that is what Modern Fortran runs in the terminal
https://github.com/fortran-lang/vscode-fortran-support/blob/8fab0851e4cf6be08f7bacc73699874b9818ee7f/src/lib/tools.ts#L148

So I am not sure I get what is going on. Did you try and update your pip version?

@JHenneberg
Copy link
Author

Thats what I did:

  • Add the --disable_autoupdate flag to fortls so as to not update upon initialisation.
  • Open a Fortran project for fortls to spawn and initialise
  • Open a terminal and run python -m pip install --user --upgrade fortls (python being the location of your Python dist)

Then I did the same again but without --user to really make sure that this is the reason why it is working and not because of some other reasons which are not apparent.

No update of pip (was anyway on latest version).

So --user it is.

@gnikit
Copy link
Member

gnikit commented Jul 5, 2022

Oh damn, I missed something! This is how fortls upgrades
https://github.com/gnikit/fortls/blob/4f17ee40647f27fbe9cc93fd1ff2b3314b866b40/fortls/langserver.py#L1759-L1767
which as you can see does not use --user. No idea how I missed that. Let me issue a release now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants