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
493 stars 78 forks source link

Crash when using sfdx-based CLI plugins: TypeError: Cannot read properties of undefined (reading 'prototype') #2508

Closed nvuillam closed 1 year ago

nvuillam commented 1 year ago

Summary

Something in salesforce/cli does not play well with sfdx plugins using sfdx architeture

2023-09-10T16:06:17.674Z sf:sfdx-hardis:hooks:init TypeError: Cannot read properties of undefined (reading 'prototype')
    at Object.<anonymous> (/home/runner/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/connection.js:28:48)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/home/runner/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/authInfo.js:25:22)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

Workarounds: uninstall the sfdx plugin then reinstall it, or downgrade to sfdx-cli instead of salesforce/cli

I'll provide more info when I can if no one else does it until that :)

github-actions[bot] commented 1 year 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.

github-actions[bot] commented 1 year ago

Hello @nvuillam :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!

mdonnalley commented 1 year ago

@nvuillam do you have steps to reproduce this error?

Also when you're in this state could you provide the output of sf plugins inspect sfdx-hardis? I'm particularly interested in what version of @salesforce/core it's using after being installed.

The stack trace you provided is referencing a file path that no longer exists in the newest version of @salesforce/core so my theory is that when your plugin is requiring @salesforce/core, it's resolving to a different major version of @salesforce/core that's somewhere else inside of sf's node_modules. This could possibly be caused by installing a plugin that requires a newer major either before or after you install sfdx-hardis

That's just my theory though - I haven't been able to replicate it yet.

mdonnalley commented 1 year ago

@nvuillam Also would be super helpful to have the output of sf version --verbose --json - thanks!

nvuillam commented 1 year ago

@mdonnalley > @CamilleGuillory had the courtesy to send that on https://github.com/Force-Config-Control/lightning-flow-scanner-sfdx/issues/79 :)


sf version --verbose --json

{
  "cliVersion": "@salesforce/cli/2.10.2",
  "architecture": "darwin-arm64",
  "nodeVersion": "node-v18.15.0",
  "osVersion": "Darwin 23.0.0",
  "shell": "zsh",
  "rootPath": "/Users/cguillory/.local/share/sf/client/2.10.2-1c35561",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.8 (core)",
    "@oclif/plugin-commands 2.2.25 (core)",
    "@oclif/plugin-help 5.2.19 (core)",
    "@oclif/plugin-not-found 2.4.1 (core)",
    "@oclif/plugin-plugins 3.7.1 (core)",
    "@oclif/plugin-search 0.0.22 (core)",
    "@oclif/plugin-update 3.2.3 (core)",
    "@oclif/plugin-version 1.3.10 (core)",
    "@oclif/plugin-warn-if-update-available 2.1.0 (core)",
    "@oclif/plugin-which 2.2.32 (core)",
    "@salesforce/cli 2.10.2 (core)",
    "apex 2.3.15 (core)",
    "auth 2.8.17 (core)",
    "data 2.5.9 (core)",
    "deploy-retrieve 1.18.0 (core)",
    "info 2.6.43 (core)",
    "limits 2.3.34 (core)",
    "login 1.2.31 (core)",
    "marketplace 0.2.2 (core)",
    "org 2.10.8 (core)",
    "packaging 1.26.3 (user)",
    "schema 2.3.26 (core)",
    "settings 1.4.29 (core)",
    "sobject 0.2.7 (core)",
    "source 2.10.34 (core)",
    "telemetry 2.3.3 (core)",
    "templates 55.5.12 (core)",
    "trust 2.6.13 (core)",
    "user 2.3.32 (core)",
    "lightning-flow-scanner 2.14.0 (user)",
    "sfdmu 4.30.0 (user)",
    "sfdx-essentials 2.12.0 (user)",
    "sfdx-git-delta 5.26.0 (user)",
    "sfdx-hardis 4.6.4 (user)",
    "texei-sfdx-plugin 2.1.2 (user)"
  ]
}
DEBUG=* sfdx flow:scan --dev-debug

/Users/cguillory/.local/share/sf/client/bin/sf flow:scan --dev-debug
SF_BINPATH=/Users/cguillory/.local/share/sf/client/bin/sf /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/bin/node /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/bin/run flow:scan --dev-debug
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561 +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/oclif.manifest.json +0ms
  config:@salesforce/cli using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/oclif.manifest.json +0ms
  config reading user plugins pjson /Users/cguillory/.local/share/sf/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json +0ms
  config loading plugins [
  { name: 'sfdx-hardis', tag: 'latest', type: 'user' },
  { name: 'sfdx-essentials', tag: 'latest', type: 'user' },
  { name: 'sfdmu', tag: 'latest', type: 'user' },
  { name: 'sfdx-git-delta', tag: 'latest', type: 'user' },
  { name: 'texei-sfdx-plugin', tag: 'latest', type: 'user' },
  { name: '@salesforce/plugin-packaging', tag: 'latest', type: 'user' },
  { name: 'lightning-flow-scanner', tag: 'latest', type: 'user' }
] +2ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/package.json/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/sfdx-git-delta +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-git-delta/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/@salesforce/plugin-packaging +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/@salesforce/plugin-packaging/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/sfdx-hardis +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/sfdx-essentials +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-essentials/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/sfdmu +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdmu/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/texei-sfdx-plugin +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/texei-sfdx-plugin/package.json +0ms
  config reading user plugin /Users/cguillory/.local/share/sf/node_modules/lightning-flow-scanner +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/lightning-flow-scanner/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-git-delta/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/texei-sfdx-plugin/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/lightning-flow-scanner/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/@salesforce/plugin-packaging/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-essentials/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdmu/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/node_modules/sfdx-essentials/.oclif.manifest.json +0ms
  config:sfdx-git-delta using manifest from /Users/cguillory/.local/share/sf/node_modules/sfdx-git-delta/oclif.manifest.json +0ms
  config:lightning-flow-scanner using manifest from /Users/cguillory/.local/share/sf/node_modules/lightning-flow-scanner/oclif.manifest.json +0ms
  config:texei-sfdx-plugin using manifest from /Users/cguillory/.local/share/sf/node_modules/texei-sfdx-plugin/oclif.manifest.json +0ms
  config:@salesforce/plugin-packaging using manifest from /Users/cguillory/.local/share/sf/node_modules/@salesforce/plugin-packaging/oclif.manifest.json +0ms
  config:sfdx-hardis using manifest from /Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/oclif.manifest.json +0ms
  config:sfdmu using manifest from /Users/cguillory/.local/share/sf/node_modules/sfdmu/oclif.manifest.json +0ms
  config:sfdx-essentials using manifest from /Users/cguillory/.local/share/sf/node_modules/sfdx-essentials/.oclif.manifest.json +0ms
  config loading plugins [
  '@oclif/plugin-autocomplete',
  '@oclif/plugin-commands',
  '@oclif/plugin-help',
  '@oclif/plugin-not-found',
  '@oclif/plugin-plugins',
  '@oclif/plugin-search',
  '@oclif/plugin-update',
  '@oclif/plugin-version',
  '@oclif/plugin-warn-if-update-available',
  '@oclif/plugin-which',
  '@salesforce/plugin-apex',
  '@salesforce/plugin-auth',
  '@salesforce/plugin-data',
  '@salesforce/plugin-deploy-retrieve',
  '@salesforce/plugin-info',
  '@salesforce/plugin-limits',
  '@salesforce/plugin-login',
  '@salesforce/plugin-marketplace',
  '@salesforce/plugin-org',
  '@salesforce/plugin-schema',
  '@salesforce/plugin-settings',
  '@salesforce/plugin-sobject',
  '@salesforce/plugin-source',
  '@salesforce/plugin-telemetry',
  '@salesforce/plugin-templates',
  '@salesforce/plugin-trust',
  '@salesforce/plugin-user'
] +8ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-autocomplete +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-autocomplete/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-commands +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-commands/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-update +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-update/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-telemetry +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-telemetry/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-help +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-help/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-not-found +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-not-found/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-plugins +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-plugins/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-search +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-search/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-version +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-version/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-warn-if-update-available +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-warn-if-update-available/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-which +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-which/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-apex +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-apex/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-auth +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-auth/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-data +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-data/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-deploy-retrieve +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-deploy-retrieve/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-info +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-info/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-limits +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-limits/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-login +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-login/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-marketplace +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-marketplace/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-org +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-org/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-schema +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-schema/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-settings +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-settings/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-sobject +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-sobject/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-source +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-source/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-templates +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-templates/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-trust +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-trust/package.json +0ms
  config reading core plugin /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-user +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-user/package.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-autocomplete/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-commands/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-update/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-telemetry/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-warn-if-update-available/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-plugins/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-not-found/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-search/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-which/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-apex/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-data/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-auth/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-version/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-limits/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-deploy-retrieve/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-help/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-info/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-marketplace/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-org/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-login/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-schema/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-sobject/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-source/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-user/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-settings/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-templates/oclif.manifest.json +0ms
  config loadJSON /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-trust/oclif.manifest.json +0ms
  config:@oclif/plugin-update using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-update/oclif.manifest.json +0ms
  config:@oclif/plugin-commands using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-commands/oclif.manifest.json +0ms
  config:@oclif/plugin-warn-if-update-available using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-warn-if-update-available/oclif.manifest.json +0ms
  config:@oclif/plugin-autocomplete using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-autocomplete/oclif.manifest.json +0ms
  config:@oclif/plugin-search using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-search/oclif.manifest.json +0ms
  config:@oclif/plugin-not-found using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-not-found/oclif.manifest.json +0ms
  config:@oclif/plugin-plugins using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-plugins/oclif.manifest.json +0ms
  config:@salesforce/plugin-telemetry using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-telemetry/oclif.manifest.json +0ms
  config:@salesforce/plugin-apex using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-apex/oclif.manifest.json +0ms
  config:@oclif/plugin-which using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-which/oclif.manifest.json +0ms
  config:@salesforce/plugin-data using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-data/oclif.manifest.json +0ms
  config:@salesforce/plugin-auth using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-auth/oclif.manifest.json +0ms
  config:@oclif/plugin-help using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-help/oclif.manifest.json +0ms
  config:@salesforce/plugin-info using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-info/oclif.manifest.json +0ms
  config:@salesforce/plugin-deploy-retrieve using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-deploy-retrieve/oclif.manifest.json +0ms
  config:@salesforce/plugin-login using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-login/oclif.manifest.json +0ms
  config:@salesforce/plugin-marketplace using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-marketplace/oclif.manifest.json +0ms
  config:@oclif/plugin-version using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-version/oclif.manifest.json +0ms
  config:@salesforce/plugin-sobject using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-sobject/oclif.manifest.json +0ms
  config:@salesforce/plugin-org using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-org/oclif.manifest.json +0ms
  config:@salesforce/plugin-user using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-user/oclif.manifest.json +0ms
  config:@salesforce/plugin-settings using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-settings/oclif.manifest.json +0ms
  config:@salesforce/plugin-templates using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-templates/oclif.manifest.json +0ms
  config:@salesforce/plugin-source using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-source/oclif.manifest.json +0ms
  config:@salesforce/plugin-schema using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-schema/oclif.manifest.json +0ms
  config:@salesforce/plugin-trust using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-trust/oclif.manifest.json +0ms
  config:@salesforce/plugin-limits using manifest from /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-limits/oclif.manifest.json +0ms
  config config done +0ms
  sf                        OS: +0ms
  sf                  platform: darwin +0ms
  sf              architecture: arm64 +0ms
  sf                   release: 23.0.0 +0ms
  sf                     shell: zsh +0ms
  sf                      NODE: +0ms
  sf                   version: 18.15.0 +0ms
  sf                       CLI: +0ms
  sf                   version: 2.10.2 +0ms
  sf                   channel: stable +0ms
  sf                       bin: sf +0ms
  sf                      data: /Users/cguillory/.local/share/sf +0ms
  sf                     cache: /Users/cguillory/Library/Caches/sf +0ms
  sf                    config: /Users/cguillory/.config/sf +0ms
  sf                       ENV: +0ms
  sf                SF_BINPATH: /Users/cguillory/.local/share/sf/client/bin/sf +0ms
  sf             SF_REDIRECTED: 1 +1ms
  sf                  SF_DEBUG: 1 +0ms
  sf                    SF_ENV: development +0ms
  sf              NODE_OPTIONS: <not set> +0ms
  sf     SF_AUTOUPDATE_DISABLE: true +0ms
  sf          SF_COMPILE_CACHE: <not set> +0ms
  sf     SF_DISABLE_AUTOUPDATE: true +0ms
  sf              SF_INSTALLER: <not set> +0ms
  sf           SF_NPM_REGISTRY: <not set> +0ms
  sf    SF_UPDATE_INSTRUCTIONS: Use "npm update --global @salesforce/cli" to update npm-based installations. +0ms
  sf                      ARGS: +0ms
  sf                         0: /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/bin/node +0ms
  sf                         1: /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/bin/run +0ms
  sf                         2: flow:scan +0ms
  config start init hook +1ms
  sf:sfdx-hardis:hooks:init TypeError: Cannot read properties of undefined (reading 'prototype')
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/connection.js:28:48)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
  sf:sfdx-hardis:hooks:init     at Module.load (node:internal/modules/cjs/loader:1117:32)
  sf:sfdx-hardis:hooks:init     at Module._load (node:internal/modules/cjs/loader:958:12)
  sf:sfdx-hardis:hooks:init     at Module.require (node:internal/modules/cjs/loader:1141:19)
  sf:sfdx-hardis:hooks:init     at require (node:internal/modules/cjs/helpers:110:18)
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/authInfo.js:25:22)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) +0ms
  sf:@oclif/plugin-update:hooks:init start (require) /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-update/lib/hooks/init.js +0ms
  sf:@oclif/plugin-warn-if-update-available:hooks:init start (require) /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@oclif/plugin-warn-if-update-available/lib/hooks/init/check-update.js +0ms
  sf:@salesforce/plugin-info:hooks:init start (require) /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-info/lib/hooks/init/init_doctor.js +0ms
  sf:@salesforce/plugin-settings:hooks:init start (require) /Users/cguillory/.local/share/sf/client/2.10.2-1c35561/node_modules/@salesforce/plugin-settings/lib/hooks/init/load_config_meta.js +0ms
  sf:sfdx-hardis:hooks:init start (require) /Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/lib/hooks/init/check-upgrade.js +13ms
  sf:@oclif/plugin-update:hooks:init done +2ms
  sf:@salesforce/plugin-settings:hooks:init done +2ms
  sf:sfdx-hardis:hooks:init done +0ms
  sf:sfdx-hardis:hooks:init TypeError: Cannot read properties of undefined (reading 'prototype')
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/connection.js:28:48)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
  sf:sfdx-hardis:hooks:init     at Module.load (node:internal/modules/cjs/loader:1117:32)
  sf:sfdx-hardis:hooks:init     at Module._load (node:internal/modules/cjs/loader:958:12)
  sf:sfdx-hardis:hooks:init     at Module.require (node:internal/modules/cjs/loader:1141:19)
  sf:sfdx-hardis:hooks:init     at require (node:internal/modules/cjs/helpers:110:18)
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/authInfo.js:25:22)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) +2ms
  sf:@salesforce/plugin-info:hooks:init done +6ms
  sf:sfdx-hardis:hooks:init TypeError: Cannot read properties of undefined (reading 'prototype')
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/connection.js:28:48)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
  sf:sfdx-hardis:hooks:init     at Module.load (node:internal/modules/cjs/loader:1117:32)
  sf:sfdx-hardis:hooks:init     at Module._load (node:internal/modules/cjs/loader:958:12)
  sf:sfdx-hardis:hooks:init     at Module.require (node:internal/modules/cjs/loader:1141:19)
  sf:sfdx-hardis:hooks:init     at require (node:internal/modules/cjs/helpers:110:18)
  sf:sfdx-hardis:hooks:init     at Object.<anonymous> (/Users/cguillory/.local/share/sf/node_modules/sfdx-hardis/node_modules/@salesforce/core/lib/authInfo.js:25:22)
  sf:sfdx-hardis:hooks:init     at Module._compile (node:internal/modules/cjs/loader:1254:14)
  sf:sfdx-hardis:hooks:init     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) +2ms
  sf:@oclif/plugin-warn-if-update-available:hooks:init done +7ms
  config init hook done +433ms
  config runCommand flow:scan [] +0ms
  perf Init Time: 446.5377ms +0ms
  perf Config Load Time: 44.1522ms +0ms
  perf Command Load Time: 0.0000ms +0ms
  perf Execution Time: 446.5357ms +0ms
  perf Core Plugin Load Time: 13.1603ms +0ms
  perf User Plugin Load Time: 7.7532ms +0ms
  perf Linked Plugin Load Time: 0.0000ms +0ms
  perf Plugin Load Times: +0ms
  perf   @salesforce/plugin-limits: 10.7070ms +0ms
  perf   @oclif/plugin-version: 10.3568ms +0ms
  perf   @salesforce/plugin-schema: 10.1573ms +0ms
  perf   @oclif/plugin-help: 10.0390ms +0ms
  perf   @salesforce/plugin-source: 9.5131ms +0ms
  perf   @salesforce/plugin-settings: 9.3535ms +0ms
  perf   @salesforce/plugin-org: 9.3162ms +0ms
  perf   @oclif/plugin-autocomplete: 9.2685ms +0ms
  perf   @salesforce/plugin-deploy-retrieve: 9.1873ms +0ms
  perf   @salesforce/plugin-trust: 9.0145ms +0ms
  perf   @oclif/plugin-commands: 8.9315ms +0ms
  perf   @salesforce/plugin-auth: 8.8525ms +0ms
  perf   @salesforce/plugin-login: 8.8154ms +0ms
  perf   @oclif/plugin-not-found: 8.8060ms +0ms
  perf   @oclif/plugin-plugins: 8.7762ms +0ms
  perf   @salesforce/plugin-marketplace: 8.7302ms +0ms
  perf   @salesforce/plugin-templates: 8.6545ms +0ms
  perf   @oclif/plugin-search: 8.5554ms +0ms
  perf   @salesforce/plugin-sobject: 8.4430ms +0ms
  perf   @salesforce/plugin-info: 8.4300ms +0ms
  perf   @oclif/plugin-which: 8.3827ms +0ms
  perf   @salesforce/plugin-data: 8.3368ms +0ms
  perf   @oclif/plugin-update: 8.2601ms +0ms
  perf   @salesforce/plugin-apex: 8.2367ms +0ms
  perf   @oclif/plugin-warn-if-update-available: 8.1275ms +0ms
  perf   @salesforce/plugin-user: 8.0515ms +0ms
  perf   sfdx-hardis: 6.1737ms +0ms
  perf   sfdx-essentials: 6.1492ms +0ms
  perf   @salesforce/plugin-telemetry: 5.9703ms +0ms
  perf   sfdmu: 5.5545ms +0ms
  perf   @salesforce/plugin-packaging: 4.0785ms +0ms
  perf   texei-sfdx-plugin: 3.8477ms +0ms
  perf   sfdx-git-delta: 3.4870ms +0ms
  perf   lightning-flow-scanner: 2.9782ms +0ms
  perf Hook Run Times: +0ms
  perf   init: +0ms
  perf     total: 433.3319ms +0ms
  perf     sfdx-hardis(./lib/hooks/init/log): 414.8917ms +0ms
  perf     @oclif/plugin-update(./lib/hooks/init): 225.9287ms +0ms
  perf     @oclif/plugin-warn-if-update-available(./lib/hooks/init/check-update): 222.0152ms +0ms
  perf     @salesforce/plugin-info(./lib/hooks/init/init_doctor.js): 220.1734ms +0ms
  perf     @salesforce/plugin-settings(./lib/hooks/init/load_config_meta): 13.7965ms +0ms
  perf     sfdx-hardis(./lib/hooks/init/check-upgrade): 12.7756ms +0ms
  perf     sfdx-hardis(./lib/hooks/init/check-local-sfdx-hardis-files): 2.3416ms +0ms
  perf     sfdx-hardis(./lib/hooks/init/start-ws-client): 1.9824ms +0ms
    TypeError: Cannot read properties of undefined (reading 'prototype')
iowillhoit commented 1 year ago

Hello all 👋 I was able to reproduce this locally, I will dig into it next week!

iowillhoit commented 1 year ago

Whew! Hey @nvuillam I was able to figure out what is going on. Under very specific circumstances yarn is getting confused about transitive dependencies. This can cause plugins still using jsforce v1 to use jsforce v2 instead.

Here is an example of what is going on with sfdx-hardis. Other plugins may need a similar fix.

To replicate this, run:

sf plugins install @salesforce/plugin-packaging
echo 'y' | sfdx plugins:install sfdx-hardis
echo 'y' | sfdx plugins:install sfdmu
echo 'y' | sfdx plugins:install sfdx-git-delta
sfdx hardis:auth:login

# [...Installs...]
# TypeError: Cannot read properties of undefined (reading 'prototype')

Sidenote: Removing any one of these plugins or even changing the install order can cause this to fail or pass. Try putting @salesforce/plugin-packaging last and it will work as expected.

To see what is going on, take a look in $HOME/.local/share/sf/node_modules

The solution is to be explicit about the version of jsforce that you need rather than counting on it being imported through @salesforce/core.

I was able to clone sfdx-hardis, add "jsforce": "1.11.0" as a dependency, install, build, and publish it to a local verdaccio registry. After setting that registry and reinstalling all the plugins, the hardis command worked as expected!

export SFDX_NPM_REGISTRY="http://localhost:4873/"
sf plugins install @salesforce/plugin-packaging
echo 'y' | sfdx plugins:install sfdx-hardis
echo 'y' | sfdx plugins:install sfdmu
echo 'y' | sfdx plugins:install sfdx-git-delta
sfdx hardis:auth:login

In this situation, another solution might be to use Connection from @salesforce/core rather than jsforce here. Then jsforce could be removed as a dependency. I did not test this though.

nvuillam commented 1 year ago

@iowillhoit thanks :) Is a fix planned ? :)

Because there are many plugins that will use jsforce v1 or v2, and it has to work ^^

iowillhoit commented 1 year ago

Hey @nvuillam 👋 From what I was able to determine, this is not a fix that can be done on our end. Yarn is going to resolve deps how it knows how to. If you have a dependency in your project that you are importing, it needs to be explicit in the dependencies section of your package.json. If you are relying on any dependency to be brought in through another package, it is bound to fail eventually.

nvuillam commented 1 year ago

With sfdx-cli such error never happened, wheareas with salesforce/cli it happens

Isn't it possible to find the delta that causes the issue ?

Most of plugins (not only sfdx-hardis!) are not upgraded to sf cli architecture, and production processes are depending on it...

iowillhoit commented 1 year ago

With the switch from sfdx to sf we did move a few plugins from being "bundled" with the CLI to being Just In Time (JIT) installed. The plugin-packaging package is one that we moved. This results in yarn operations (adds and installs) to happen in your $HOME/.local/shared/sf directory the first time the command is ran.

If I had to guess it is just a balance of who wants what dependencies when yarn is trying to resolve them. Like I mentioned above, installing plugin-packaging first rather than last will result in different outcomes. We cannot control how yarn resolves dependencies. If your package needs a dependency that you are importing, it needs to be explicit in your packages' package.json, otherwise it is bound to break.

nvuillam commented 1 year ago

I made an attempt... let's hope it will work ^^

iowillhoit commented 1 year ago

I was just able to install and run this without any issues:

sf plugins install @salesforce/plugin-packaging
echo 'y' | sfdx plugins:install sfdx-hardis
echo 'y' | sfdx plugins:install sfdmu
echo 'y' | sfdx plugins:install sfdx-git-delta
sfdx hardis:auth:login

This was consistently failing prior to your recent release of sfdx-hardis. It is possible that other plugins with need to also be explicit about their dependencies also, but at least one of these appears to be resolved.

nvuillam commented 1 year ago

Problem solved in sfdx-hardis v4.6.5 :)

-> https://github.com/hardisgroupcom/sfdx-hardis/releases/tag/v4.6.5

@iowillhoit many thanks for your assistance :)