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

[BUG] - On Mac, 'Pascal: Generate tags' command fails with error: "gtags: directory '' not found.\n" #156

Open
ansumanm opened this issue Dec 1, 2024 · 1 comment
Labels

Comments

@ansumanm
Copy link

ansumanm commented Dec 1, 2024

Environment/version

  • Extension version: v9.8.0
  • VSCode version: Version: 1.95.3 (Universal)
  • OS version: MacOS Sonoma 14.6.1

Steps to reproduce

  1. Open a folder containing Pascal files in vscode
  2. Execute command -> Pascal: Generate Tags.

The proper error does not come up in the Vscode error pop-up. I only see:- "Some error occurred {0}".
So I cloned the extension and debugged it. On the debug window, I see stderr = "gtags: directory '' not found.
Screenshot attached.

Screenshot 2024-12-01 at 10 22 43 AM

I debugged a bit more and see that the basePath variable is valid inside the generateTags function, but not inside the Promise. I am not an expert on Javascript/Typescript and sound stupid.
Screenshot attached:
Screenshot 2024-12-01 at 10 27 02 AM

I hope this helps. Please let me know if you need anything else. Please let me know if I can contribute in anyway.

@ansumanm
Copy link
Author

ansumanm commented Dec 2, 2024

I was doing a bit of debugging myself. And I think I found the issue. It is with the tagsBuilder.ts where we are setting params = "" (line np. 25)

export class TagsBuilder {

public generateTags(basePath: string, update: boolean, showMessage?: boolean): Promise<string> {

    return new Promise<string>((resolve, reject) => {

        let command: string = update ? "global" : "gtags";
        let params: string = update ? "--update" : "";

        if (!TagsBuilder.tagsAvailable(path.join(basePath, 'GTAGS'))) {
            command = "gtags";
            params = "";
        }

		const statusBar: vscode.Disposable = vscode.window.setStatusBarMessage("Generating tags...");
        cp.execFile(command, [params], { cwd: basePath }, (err, stdout, stderr) => {

Now when the the params is passed to cp.execFile, the command is being executed as:
$ gtags ""

This gives the error:-
% gtags ""
gtags: directory '' not found.

Which is seen in the stderr in my screenshot.

I wrote a test extension - gtags runner to debug this.
And for me the this works gtags works fine. This is how my code looks like (just pasting the relevant parts.). I am passing an empty array instead of [""] to gtags as an argument.:

const gtagsPath = 'gtags'; // Adjust this if `gtags` is located elsewhere
const options = { cwd: folderPath };

vscode.window.showInformationMessage(`Running gtags in: ${folderPath}`);

cp.execFile(gtagsPath, [], options, (err, stdout, stderr) => {

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

No branches or pull requests

1 participant