alefragnani / vscode-language-pascal

Pascal language extension for Visual Studio Code
MIT License
222 stars 47 forks source link

gtags: directory '' not found #61

Closed vintprox closed 4 years ago

vintprox commented 4 years ago

After installing dependencies (GNU Global, ctags, gtags, python and pygments), reloading everything and editing *.pas, I keep getting following error in VSC:

Some error occured: Error: Command failed: gtags 
gtags: directory '' not found.

Consequently, I cannot harness extension's code navigation.

OS: Ubuntu 20.04 (Linux x64 5.4.0-31-generic) Visual Studio Code: 1.45.1

alefragnani commented 4 years ago

Hi @vintprox ,

Where / when do you see this error message? Which command are you running?

The extension depends on these tools working properly (installed and configured as described in README.md) on you machine, so I suggest you to run them via shell, to make sure it is being recognised by VS Code.

  1. Open a shell terminal
  2. Navigate to your project's folder.
  3. Run gtags (no params)
  4. It should create 3 files named GTAGS, GPATH and GRTAGS
  5. If not, something is not correct in the installation/settings
  6. If yes, run global -f relativePath/someOfYourFile.pas
  7. It shoud list every method/function inside that file
  8. If not, something is not correct in the installation/settings
  9. If yes, for some reason VS Code doesn't recognise the settings/PATH.

I don't know about Linux, but I suppose it works similar to MacOS on this matter, so I guess some of the tips in #24 should similar to you.

Hope this helps

alefragnani commented 4 years ago

I'm closing this issue because no new comments has been made since my last question. Feel free to reopen/comment if the error still occurs.

trey-k commented 3 years ago

Don't think remote support is available yet based on #52 but I'm experiencing this same error trying to generate tags on a remote SSH server. I can run gtags in shell and look at the results fine with global -f file and everything appears to be in my PATH. Extension appears to work over remote so long as I generate the tags myself but I can't find any additional logging about the error in console.

Have set GTAGSCONF, GTAGSLABEL and PYTHONPATH (suggested by #24) and have them seen by VSCode terminal, the variables are also read correctly by gtags when running with gtags -v in terminal

OS: Ubuntu 20.04 (Linux 5.4.0-66-generic) VSCode: 1.55.0

alefragnani commented 3 years ago

Hi @trey-k ,

It's been a long time I don't need to use SSH, but based on VS Code documentations, it should work quite similar to Docker (when it comes to how extensions should work), which I use quite frequently. And you are right, the extension does not support any remotes, yet.

I don't use FreePascal and just recently started using Linux (on Docker/WSL), and I wasn't able to properly install/setup global / gtags / python, so the extension can see them. Could you help me on that?

If you could provide the instructions to install/setup them on Linux/Docker environment, I would be able to test and hopefully, make the extension properly support Remotes.

One thing you should take in consideration. Some extensions requires to be installed on remotes, mostly because the need to access tools/resources on that remote. I'm not entirely sure, but I suppose this will be the case for the Pascal extension too. But that's not a big issue, because you can easily setup it on your settings.

BTW, the idea of #52 is to make the extension to support Remotes, and #66 is to support Codespaces (which uses a container/web based scenario). These are complementary issues.

Thank you

trey-k commented 3 years ago

@alefragnani I can walk through what I did so far, I already do have the extensions installed and running on the server even if they aren't remote compatible, let me know if I'm missing anything.

I'm on Ubuntu 20.04 so I just went with the available packages on my remote server:

sudo apt update
sudo apt install global exuberant-ctags python3-pygments

After installing I set GTAGSCONF and GTAGSLABEL environment variables as described in your own setup:

There is no default gtags.conf file on Linux so I copied mine from the Windows setup and put it at /etc/gtags.conf.

export GTAGSCONF=/etc/gtags.conf
export GTAGSLABEL=pygments

Once everything is setup you can go to your project directory and run gtags -v for verbose output, it should say it's using the configuration specified by GTAGSCONF and that it is using the label 'pygments'. In addition to seeing gtags processing files you should now be able to use global -f file.pas to see generated tags, that's it!

If anything seems wrong the --explain option helped me figure some things out initially but I'm happy to help with more installation/testing if needed. I had one little headache along the way not remembering the Linux filesystem was case sensitive so I had to add the uppercase extension to my configuration file too.

Add to remote settings JSON if you want to have the variables set every session:

{
    "terminal.integrated.env.linux": {
        "GTAGSCONF": "/etc/gtags.conf",
        "GTAGSLABEL": "pygments"
    }
}
alefragnani commented 3 years ago

Hi @trey-k ,

Thanks for the detailed steps. I’ll try out, and if everything goes ok, it should be easier to update the extension to support remotes.

Stay tuned

ansumanm commented 4 days ago

Hi @vintprox ,

Where / when do you see this error message? Which command are you running?

The extension depends on these tools working properly (installed and configured as described in README.md) on you machine, so I suggest you to run them via shell, to make sure it is being recognised by VS Code.

  1. Open a shell terminal
  2. Navigate to your project's folder.
  3. Run gtags (no params)
  4. It should create 3 files named GTAGS, GPATH and GRTAGS
  5. If not, something is not correct in the installation/settings
  6. If yes, run global -f relativePath/someOfYourFile.pas
  7. It shoud list every method/function inside that file
  8. If not, something is not correct in the installation/settings
  9. If yes, for some reason VS Code doesn't recognise the settings/PATH.

I don't know about Linux, but I suppose it works similar to MacOS on this matter, so I guess some of the tips in #24 should similar to you.

Hope this helps

Please add these debug steps to the Readme/Project page. This was very helpful in debugging my environment. I am able to start using this now. But still "Pascal: generate tags" and "Pascal: Update tags" commands are not working in VSCode environment. I have to manually generate the tags ('gtags') and then restart my VSCode to read fresh tags. Also "Find All References" and "Go to References" is not working. And BTW, thanks for this wonderful Pascal extension.