Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
connor4312 opened this issue Jan 12, 2022 · 1 comment
Closed

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

connor4312 opened this issue Jan 12, 2022 · 1 comment

Comments

@connor4312
Copy link

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.

@svsool
Copy link
Owner

svsool commented Jan 13, 2022

Hi @connor4312, thanks for heads up!

I'll test it later this week. 👍

I assume rgPath export is already available?

Should it be also node_modules.asar.unpacked vs node_modules.asar

That's how VS Code directory looks locally for me:

image

Update: checked and seems like rgPath export is not yet available.

svsool added a commit that referenced this issue Jul 30, 2022
@svsool svsool closed this as completed Jul 30, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants