Cli: force:apex:execute on salesforce cli 7.73.1-67933dd254 returning "Error: Cannot find module './tests'"

Created on 5 Sep 2020  路  11Comments  路  Source: forcedotcom/cli

Summary

After installing salesforce cli on a linux github runner and trying to execute force:apex:execute I'm receiving the stack trace mentioned down bellow.

Steps To Reproduce:

On a Linux Github runner download and install the latest cli:

$ wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
$ mkdir -p sfdx-cli
$ tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
$ ./sfdx-cli/install
sfdx installed to /usr/local/bin/sfdx
sfdx-cli/7.73.1-67933dd254 linux-x64 node-v12.18.3

And then, after connecting with a sandbox/org using JWT oauth flow, try to force:apex:execute:

$ sfdx force:apex:execute -f scripts/apex/CreateBaseData.apex -u sdx

Expected result

Apex executed properly.

Actual result

Receiving the following stack trace:

Error: Cannot find module './tests'
    Require stack:
    - /usr/local/lib/sfdx/node_modules/@salesforce/apex-node/lib/src/index.js
    - /usr/local/lib/sfdx/node_modules/@salesforce/plugin-apex/lib/commands/fo
    rce/apex/execute.js
    - /usr/local/lib/sfdx/node_modules/@oclif/config/lib/plugin.js
    - /usr/local/lib/sfdx/node_modules/@oclif/config/lib/config.js
    - /usr/local/lib/sfdx/node_modules/@oclif/config/lib/index.js
    - /usr/local/lib/sfdx/node_modules/@oclif/command/lib/command.js
    - /usr/local/lib/sfdx/node_modules/@oclif/command/lib/index.js
    - /usr/local/lib/sfdx/dist/cli.js
    - /usr/local/lib/sfdx/bin/sfdx.js
    Code: MODULE_NOT_FOUND

Additional information

# Unique name for this workflow
name: On push feature-rm - Deploy to TU01

# Definition when the workflow should run
on:
    push:
        branches:
            - feature-rm/*/*

# Jobs to be executed
jobs:
    build-deploy:
        runs-on: ubuntu-latest
        steps:

            # Checkout the code in the pull request
            - name: 'Checkout source code'
              uses: Professiona-Services-LATAM/checkout@v2

            - name: 'Build and Deploy'
              uses: Professiona-Services-LATAM/sfdx-orgdev-build-deploy@v2
              with:
                type: 'sandbox'
                certificate_path: devops/server.key.enc
                decryption_key: ${{ secrets.DECRYPTION_KEY_NON_PRODUCTIVE }}
                decryption_iv: ${{ secrets.DECRYPTION_IV_NON_PRODUCTIVE }}
                client_id: ${{ secrets.CONSUMER_KEY_TU01 }}
                username: ${{ secrets.USERNAME_TU01 }}
                checkonly: false
                destructive_path: destructive
                manifest_path: manifest/package-baseDeploy.xml
                data_factory: scripts/apex/CreateBaseData.apex

Most helpful comment

Our workaround for now - lock to older SFDX cli archive. Thankfully available here if anyone needs a solution for the time being.
https://developer.salesforce.com/media/salesforce-cli/sfdx-cli/channels/stable/sfdx-cli-v7.72.0-697e9faee2-linux-x64.tar.xz

All 11 comments

Can absolutely confirm that!
CI worked with sfdx-cli/7.72.0-697e9faee2 but fails now with sfdx-cli/7.73.1-67933dd254

Also seeing this issue.

Looks like one or more files used in @salesforce/apex-node have not been committed to the repo (ie there is a missing 'tests' folder on their end). Looks like the repo (https://github.com/forcedotcom/salesforcedx-apex) is private so hopefully someone with access sees this report.

Our workaround for now - lock to older SFDX cli archive. Thankfully available here if anyone needs a solution for the time being.
https://developer.salesforce.com/media/salesforce-cli/sfdx-cli/channels/stable/sfdx-cli-v7.72.0-697e9faee2-linux-x64.tar.xz

Thanks for the URL @jordanhenderson!
How did you get that? Is there somewhere a public listing available?

The workaround provided by jordanhenderson worked perfectly for our CI. Thanks @jordanhenderson!

Hi @tiagonnascimento thanks for reporting this! There were a few issues with cli version sfdx-cli/7.73.1, but we released a fix with sfdx-cli/7.73.2 that should address those. Can you try updating to the latest version and see if that fixes your issues? If it doesn't, could you also run sfdx plugins --core and paste the output here?

@schmalli I used the manifest available here - https://developer.salesforce.com/media/salesforce-cli/manifest.json
@AnanyaJha this appears to still be on version 7.73.1, not sure if we should be seeing the new version here already for those who install sfdx via the archive directly.

@jordanhenderson Looks like the archive didn't get updated with the latest release; we'll update it with the next release this Thursday 09/10. For now, I recommend sticking with the workaround and we'll continue looking into it!

@AnanyaJha, I tried today, but downloading thru Github Runner I'm still getting 7.73.1. I will try once again in few days as you mentioned. Thanks!

Thw archives have been updated to todays release; 7.74.1.

Was this page helpful?
0 / 5 - 0 ratings