Gruntfuggly / todo-tree

Use ripgrep to find TODO tags and display the results in a tree view
Other
1.42k stars 137 forks source link

Action needed: update your import of the built-in ripgrep #596

Closed connor4312 closed 1 year ago

connor4312 commented 2 years ago

Hello from the VS Code team 👋

We're doing some housekeeping that involves renaming some of our internal packages. Namely, vscode-ripgrep will be renamed to @vscode/ripgrep, which affects its location in VS Code's node_modules folder. It looks like this extension depends on vscode-ripgrep in a way that will break when this rename happens.

We suggest either:

  1. Adding an extra check for the renamed binary path in your extension, or
  2. Updating your extension to import vscode-ripgrep and retrieve the binary path from there. We will alias the require statement, so that the renamed package is always resolved correctly, and vscode-ripgrep exports the binary path. For example:

    function getCoreNodeModule(moduleName) {
      try {
          return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);
      } catch (err) {
          try {
              return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);
          } catch (err) {
              return undefined;
          }
      }
    }
    
    const { rgPath } = getCoreNodeModule('vscode-ripgrep');
    // then child_process.spawn(rgPath, [...

    Note that if you're building your extension with Webpack, you will want to use __non_webpack_require__ instead of require, otherwise webpack will try to (incorrectly) resolve the request by itself.

Gruntfuggly commented 2 years ago

I can't get your example code to work - it seems to return the first "require" in the try block, but the path to the binary that is returned doesn't exist?

i.e, the getCoreNodeModule function returns:

/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/node_modules.asar/@vscode/ripgrep/bin/rg

In my installation, there is a node_modules.asar.unpacked folder, but no node_modules.asar folder.

I don't really understand how it all works, but simply looking for @vscode/ripgrep when vscode-ripgrep is not found, does work, so I've gone with that for now.

1Luc1 commented 2 years ago

With the latest version @ manjaro i got the following error Todo-Tree: Failed to find vscode-ripgrep - please install ripgrep manually and set 'todo-tree.ripgrep' to point to the executable

My version is

Version: 1.64.0
Commit: 5554b12acf27056905806867f251c859323ff7e9
Datum: 2022-02-03T22:59:58.092Z
Electron: 13.6.8
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.40-electron.0
Betriebssystem: Linux x64 5.16.5-1-MANJARO
Gruntfuggly commented 1 year ago

Closing as I don't think this is relevant anymore.