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

Installing findent through pip with --user option #582

Closed
ggerber opened this issue Jul 22, 2022 · 5 comments
Closed

Installing findent through pip with --user option #582

ggerber opened this issue Jul 22, 2022 · 5 comments

Comments

@ggerber
Copy link

ggerber commented Jul 22, 2022

I installed fortls v2.12.0 and findent v4.2.0 with pip on ubuntu 21.10.

findent is located at ~/.local/bin/findent
fortls is located at ~/.local/bin/fortls

~/.local/bin is on my PATH

I installed the Modern Fortran v3.2.0 extension in VSCode.

Every time I try to save the following file with unmatched indentation

program hello
    ! This is a comment line; it is ignored by the compiler
    print *, 'Hello, World!'
    end program hello

I get the VS Code message: "Installing findent through pip with --user option"
The indentation is not fixed on the "end program hello" line

@gnikit
Copy link
Member

gnikit commented Jul 22, 2022

Hi @ggerber please follow the instructions on the reporting a bug template and provide additional information on how to replicate the issue.

Btw we are not responsible for authoring findent. This is the repo findent repo to report bugs to https://github.com/wvermin/findent

@ggerber
Copy link
Author

ggerber commented Jul 22, 2022

Describe the bug

Every time I try to save the following file with unmatched indentation

program hello
    ! This is a comment line; it is ignored by the compiler
    print *, 'Hello, World!'
    end program hello

I get the VS Code message: "Installing findent through pip with --user option"
The indentation is not fixed on the "end program hello" line

I also observe the following uncaught error logged in the runtime status of the Modern Fortran extension:
The argument 'file' cannot be empty. Received ''

To Reproduce

From the commandline:

pip cache purge
pip install fortls findent

Installing collected packages: fortls, findent                                                                                                                                                                                                                                                                             
Successfully installed findent-4.2.0 fortls-2.12.0

Open VSCode
Install the Modern Fortran extension.
Check the extensions run time status to observe the uncaught error:

The argument 'file' cannot be empty. Received ''

Create the following file hello.f90

program hello
    ! This is a comment line; it is ignored by the compiler
    print *, 'Hello, World!'
    end program hello

In the editor for the file hello.f90 press ctrl+s to save.
Observe the VS Code recommnedation:
"Installing findent through pip with --user option"
Choose "install"

In the editor for the file hello.f90 press ctrl+s to save.
Observe the VS Code recommnedation:
"Installing findent through pip with --user option"
Choose "install"

In the editor for the file hello.f90 press ctrl+s to save.
Observe the VS Code recommnedation:
"Installing findent through pip with --user option"
Choose "install"

repeat

Expected behavior

  1. There should be no uncaught errors in the extension's runtime status.
  2. The extension should not request the user to install findent every time the hello.f90 file is saved with ctrl+s
  3. The indentation should automatically be fixed on the hello.f90 file shown above

Priority

P2 - cumbersome to manually fix indentation

Desktop

  • OS: Ubuntu 21.10

@gnikit
Copy link
Member

gnikit commented Aug 1, 2022

The formatter, both the installing and spawning have tests in the extension so they work as expected. I also did a sanity check now and I can confirm that as well. I think there is a lot to unpack here, but my guess would be that there is something wrong with your installation either vscode or Modern Fortran.
You need to provide the version of VS Code, your settings, etc. These are the things that make an issue replicable.


I get the VS Code message: "Installing findent through pip with --user option" The indentation is not fixed on the "end program hello" line

This should trigger if you don't have findent installed in your system OR it's not discoverable in your $PATH. From the rest of your answer it looks like you have installed it, but the VS Code extension is unable to find it. Have you tried pointing VS Code to the formatter?

{
  // location of the findent binary, note: do not add `findent` in the end
  "fortran.formatting.path": "./custom/path/venv/bin"
}

I also observe the following uncaught error logged in the runtime status of the Modern Fortran extension: The argument 'file' cannot be empty. Received ''

I can't replicate that. Could be happening for any number of reasons, all most likely unrelated to the actual extension. My guess is that you have old versions of the extensions cached in your system, or your vscode cache needs purging.

In the editor for the file hello.f90 press ctrl+s to save. Observe the VS Code recommnedation: "Installing findent through pip with --user option" Choose "install"
repeat

Looks like you have format on save (or some other editor event) enabled when it comes to formatting. Since I can't replicate any of your issues, you will need to disable and bring the VS Code installation and Modern Fortran installation as close to default as possible. The start enabling your own settings to see what causes this.

Check your installed vscode extensions ~/.vscode/extensions/ there should be only one extension containing the name linter-gfortran. Deleting any and all folders that include that name will truly uninstall the extension(s).

@ggerber
Copy link
Author

ggerber commented Aug 2, 2022

Thank you @gnikit
The issue was resolved by reinstalling vscode and setting correctly the path to the findent folder (i.e. excluding the findent filename from the path) as recommended
{
// location of the findent binary, note: do not add findent in the end
"fortran.formatting.path": "./custom/path/venv/bin"
}

@gnikit
Copy link
Member

gnikit commented Aug 2, 2022

Glad to hear it @ggerber. I might have to change the way you are allowed to pass your formatting binary to vscode.

I initially coded it that way, concatenating the binary name, to ensure that when you do input ./path/to/formatter/ you can always guarantee that the binary you are calling is the formatter you have chosen in the settings.

It would appear that is confusing and users seem to expect that this option should be the full binary path.

I think I might have to redesign the settings to something closer to Python's extension that does something similar.

I'll be closing this now, glad you were able to resolve it.

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

No branches or pull requests

2 participants