forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
474 stars 77 forks source link

Salesforce CLI link plugin issue #2915

Closed JaniszewskiMarcin closed 3 weeks ago

JaniszewskiMarcin commented 3 weeks ago

Summary

When updating CLI version to the latest one we can not link plugins. Error message: "@salesforce/cli: Linking plugin ../pluginName... ! › Error: /usr/local/lib/node_modules/@salesforce/cli/node_modules/npm/bin/np › m-cli.js install --no-audit --loglevel=silent --no-fund exited with code 2 › Try this: Run with DEBUG=@oclif/plugin-plugins* to see debug output."

We start to observe this errors happening from version 2.35.6 (April 3, 2024) and even now the newest version 2.44.8 (Jun 5, 2024) [stable] still causes same issues.

Steps To Reproduce

  1. Update CLI version to the newest one for now 2.44.8 (Jun 5, 2024).
  2. Try to link plugin from your local device.

Expected result

Proper plugin linking.

Actual result

Plugin is not linked and can not be use in other parts of script.

System Information

Additional information

No additional information.

github-actions[bot] commented 3 weeks ago

Hello @JaniszewskiMarcin :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

github-actions[bot] commented 3 weeks ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

cristiand391 commented 3 weeks ago

could you run the command with this env var set and share the output? DEBUG=@oclif/plugin-plugins*

JaniszewskiMarcin commented 3 weeks ago

Below you can find an output:

(node:32552) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) @oclif/plugin-plugins installing dependencies with npm +0ms @oclif/plugin-plugins:npm npm binary path C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js +0ms @oclif/plugin-plugins:npm C:\Users\marcin.janiszewski\Desktop\Repositories\sfdx-project: C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js install --no-audit --loglevel=silent --no-fund +0ms @oclif/plugin-plugins:spawn modulePath node +0ms @oclif/plugin-plugins:spawn args [ '"C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js"', 'install', '--no-audit', '--loglevel=silent', '--no-fund' ] +0ms @oclif/plugin-plugins:spawn node_modules/@salesforce/core/lib/org/authInfo.d.ts(3,10): error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'? +8s @oclif/plugin-plugins:spawn node_modules/@salesforce/core/lib/webOAuthServer.d.ts(3,10): error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'? +0ms
@oclif/plugin-plugins:npm npm error CLIError: node "C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js" install --no-audit --loglevel=silent --no-fund exited with code 2 at ChildProcess. (file:///C:/Users/marcin.janiszewski/AppData/Roaming/npm/node_modules/@salesforce/cli/node_modules/@oclif/plugin-plugins/lib/spawn.js:70:24) at ChildProcess.emit (node:events:515:28) at ChildProcess.emit (node:domain:488:12) at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) { code: undefined, oclif: { exit: 2 }, skipOclifErrorHandling: undefined, suggestions: [ 'Run with DEBUG=@oclif/plugin-plugins to see debug output.' ] } +8s @salesforce/cli: Linking plugin ../sfdx-project... ! » Error: node "C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js" install --no-audit --loglevel=silent --no-fund exited with code 2 » Try this: Run with DEBUG=@oclif/plugin-plugins to see debug output.

cristiand391 commented 3 weeks ago

That's a typescript error but sf plugins link doesn't build your plugin when you link it 🤔

could it be that you have a postinstall script in your plugin that tries to build it? if so, you might need to fix the error in your plugin first.

JaniszewskiMarcin commented 3 weeks ago

Ticket to be closed indeed there was deprecated member named 'JwtOAuth2Config' should be 'OAuth2Config' in my scripts. Main issue was that in Visual Studio Code search function do not scan all the files and I assumed we do not have any of those variables or at least not on our side. Thanks for help!

JaniszewskiMarcin commented 3 weeks ago

Since problem is resolved I'am closing the issue.