forcedotcom / sfdx-scanner

MIT License
217 stars 49 forks source link

Unable to install sfdx-scanner plugin #1019

Closed ronika-das closed 1 year ago

ronika-das commented 1 year ago

Hi team Describe the bug I am not able to install the plugin on my CI/CD pipelines on gitlab. It gets stuck on polling

To Reproduce I am running the below commands: $ npm config set strict-ssl=false $ sfdx plugins:install @salesforce/sfdx-scanner

I am setting the ssl to false as I am trying to install the plugin behind company firewall. We want to try pmd scanner for our teaml After the second command, it gets stuck at polling

Expected behavior The plugin to be installed and Screenshots If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information): We are using Gitlab to execute the commands. The docker image has node, salesforce cli and java. Normal sfdx commands work fine.

Additional context Before setting the ssl to False, I would get this error "npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY"

Workaround: Have you found any ways to sidestep the problem? Not yet

Urgency: How severe is this problem? "Business stopping" vs "Not business-stopping". Not business-stopping. We want to try to use this plugin and see if it can be an alternative to other scanning tools.

rmohan20 commented 1 year ago

Hi @ronika-das - thanks for letting us know. Can you check and tell us what versions of Node and Salesforce CLI your docker image has?

sfdx --version

Also, can you update to the latest and retry?

ronika-das commented 1 year ago

Hi @rmohan20 Yes sure

Node version -> v14.21.1 Salesforce CLI version -> sfdx-cli/7.171.0 I tried updating the cli to the latest version. After that, the plugin install command is running for a long time. It has been more than 10 mins. Below image is my attempt

image

May I know if there is any alternative (maybe npm) command for installing the plugin?

rmohan20 commented 1 year ago

Thanks @ronika-das. I'm unable to repro your issue in my local. As you mention, sounds like an env-related issue. Salesforce CLI has added a new feature to auto-detect and install plugins. Wonder if this may work better for you.

Can you directly execute:

sfdx scanner:rule:list

If it fails with an "Attempted to resolve unregistered dependency token: 'RuleManager'", rerun the same command and this should complete the installation.

Let us know how this works for you.

rmohan20 commented 1 year ago

Also, if you're simply trying out the tool, might be easier to directly install it on your local machine. This way, you can play around with the various options against your codebase to see how you want to use it.

mitchspano commented 1 year ago

I am experiencing the same issue after a fresh install of sfdx CLI

# remove old installation
sudo npm uninstall sfdx-cli --global
sudo rm -rf /usr/local/sfdx
sudo rm -rf /usr/local/lib/sfdx
sudo rm -rf /usr/local/bin/sfdx
sudo rm -rf ~/.local/share/sfdx ~/.config/sfdx ~/.cache/sfdx
sudo rm -rf ~/Library/Caches/sfdx
sudo rm -rf /usr/local/sf
sudo rm -rf /usr/local/bin/sf

# install fresh
sudo npm i sfdx-cli --global

# verify installation
sfdx -v
sfdx-cli/7.192.2 darwin-x64 node-v16.13.1

# attempt to install scanner plugin
sfdx plugins:install @salesforce/sfdx-scanner
# gets stuck here
Polling for new version(s) to become available on npm... ⣟ attempt: 203 of 300
ronika-das commented 1 year ago

@rmohan20 For me personally, it is loading on the local system. However we want to try it on the CI/CD pipelines on Gitlab and wanted to be proactive :D

Here is my attempt at running

sfdx scanner:rule:list

It is not progressing and it has been more than 10mins

image

Thanks!

iowillhoit commented 1 year ago

Hi all 👋 I am on the Salesforce CLI team. I am also unable to reproduce this locally. Is this just happening with @salesforce/sfdx-scanner or are you seeing it with other packages also? Here are a few that you could try: sfdx plugins install @salesforce/plugin-release-management (Signed package. Used for our release processes) sfdx plugins install @cristiand391/sf-plugin-api (Unsigned package. SF API wrapper from one of our team members)

Could someone also try with debug logs? DEBUG=* sfdx plugins install @salesforce/sfdx-scanner

rmohan20 commented 1 year ago

@ronika-das @mitchspano Can either of you try out the troubleshooting steps that @iowillhoit has recommended above and let us know your findings, please?

ronika-das commented 1 year ago

Hi all @rmohan20 @iowillhoit

Very strange, Today I am able to install and plugin and run the scanner:run command. Here is a look at the time. Seems something worked on its own haha :D I am going to try it out more and check

image

I was also able to install the mentioned plugins by running the below commands

ronika-das commented 1 year ago

FYI, I did not do additional changes from side. Just reran the same set of commands as in first comment

$ npm config set strict-ssl=false $ sfdx plugins:install @salesforce/sfdx-scanner $ sfdx scanner:rule:list $ sfdx scanner:run --target "/default/" --format "csv" --outfile "build/pathToFile.csv"

mitchspano commented 1 year ago

I was able to install using sudo

rmohan20 commented 1 year ago

@ronika-das @mitchspano Thanks for reporting back. Still unclear what caused the issue. Will close this for now since there doesn't seem to be any action needed at the moment.