Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

/bin/sh: cfn-lint: command not found when installed in virtual environment virtualenv #211

Open
felipe1982 opened this issue Jan 12, 2022 · 7 comments

Comments

@felipe1982
Copy link

felipe1982 commented Jan 12, 2022

I am getting the following error when viewed in the Output window at the bottom of vscode. I have latest stable vscode, with latest stable version of cfn-lint, with latest stable version of Cloudformation Linter extension.

Settings have been updated...
Settings: {"cfnLint":{"enableAutocomplete":true,"validateUsingJsonSchema":false,"path":"cfn-lint --ignore-checks E3012 E3031","appendRules":[],"ignoreRules":[],"overrideSpecPath":""}}
Determined this file is a CloudFormation Template. file:///home/felipe/repos/sdlf-cicd/template-cicd-child-foundations.yaml. Found the string AWSTemplateFormatVersion
Running... cfn-lint --ignore-checks E3012 E3031 --format,json,--,"/home/felipe/repos/sdlf-cicd/template-cicd-child-foundations.yaml"
/bin/sh: cfn-lint: command not found

child process exited with code 127 and signal null

I have cfn-lint installed in a virtual environment ~/.venv using python -m venv ~/.venv and then pip install --upgrade cfn-lint.

  • I have selected my .venv/bin/python to be my default interpreter
  • I have tried to delete my venv, and create a new one, with same result

OS Windows 10
WSL2 OpenSUSE 15.3
cfn-lint --version cfn-lint 0.56.4
python Python 3.6.15

which cfn-lint python python3
/home/felipe/.venv/bin/cfn-lint
/home/felipe/.venv/bin/python
/home/felipe/.venv/bin/python3

VSCODE
Version: 1.63.2 (user setup)
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:40:02.816Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19042

@felipe1982
Copy link
Author

felipe1982 commented Jan 28, 2022

I have since moved to using pipenv for my virtual environments, and I get exactly the same problem. My co-worker, who was just hired 2 weeks ago, with fresh install of VSCode and WSL2 has exactly the same problem.

@kddejong
Copy link
Contributor

You can set the path to cfn-lint in the settings of the plugin.

{
  ...
  "cfnLint.path": "/home/felipe/.venv/bin/cfn-lint"
  ...
}

We default it to cfn-lint and rely on the location being inside the Path environment variable. Depending on how you start VSCode that may or may not be available. We do allow you to override where it looks as needed using the setting above.

@felipe1982
Copy link
Author

felipe1982 commented Jan 28, 2022

I'll give it a try. Thank you. Would you happen to know what is the cause? A recent code change, or vscode change? It's been working with my virtual environment for around 4 years without fail.

@felipe1982
Copy link
Author

felipe1982 commented Feb 7, 2022

I start VSCode by opening the icon on my desktop.

While setting the path in vscode settings does work, I feel that that shouldn't be the solution. pipenv and virtual environments are supported by dozens of other extensions, without having to set the path in each of them. Is there anything else can I can provide to help solve this particular problem?

@johncuyle
Copy link

You can set the path to cfn-lint in the settings of the plugin.

{
  ...
  "cfnLint.path": "/home/felipe/.venv/bin/cfn-lint"
  ...
}

We default it to cfn-lint and rely on the location being inside the Path environment variable. Depending on how you start VSCode that may or may not be available. We do allow you to override where it looks as needed using the setting above.

Unfortunately this doesn't work for the relatively common case of developing under both Windows and WSL. For working in Windows, the path needs to be ".venv\Scripts\cfn-lint", for linux under WSL it needs to be ".venv/bin/cfn-lint". The plugin really should try the configured virtual environment before falling back to PATH.

@dprangnell
Copy link

I always create my virtual environment in a folder called venv and setting this worked for me:

{
  ...
  "cfnLint.path": "./venv/bin/cfn-lint"
  ...
}

@kathyrollo
Copy link

Still encountering this issue in 2024. I am working under WSL2. The comment from @johncuyle worked. I have a .venv/ dir in my repo, so I modified the .vscode/settings.json:

{
  "cfnLint.path": ".venv/bin/cfn-lint"
}

Do not forget to restart VS Code for the settings to take effect.

You can find the path of the cfn-lint executable by running the which cfn-lint command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants