Giter VIP home page Giter VIP logo

Comments (12)

rderveloy avatar rderveloy commented on August 25, 2024 1

I'm having the same exact issue as @ducoterra as well. I'm running version 1.7.0 of the extension in VS Code 1.55.0 on MacOS 10.15.7. I have verified that the virtual environment is activated, that dependencies are installed, and that the virtual environment is selected in VS Code per the instructions on the extension's detail page:

Command failed: python /Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/resources/python/checkVenv.py
Error: Command failed: python /Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/resources/python/checkVenv.py
	at checkExecSyncError (child_process.js:639:11)
	at Object.execSync (child_process.js:675:15)
	at Object.execSync (electron/js2c/asar_bundle.js:5:12113)
	at Function.isInVirtualEnv (/Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/out/main/utils/pypiUtils.js:91:18)
	at Function.createDependenciesTrees (/Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/out/main/utils/pypiUtils.js:67:28)
	at processTicksAndRejections (internal/process/task_queues.js:97:5)
	at async Function.createDependenciesTrees (/Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/out/main/treeDataProviders/dependenciesTree/dependenciesTreeFactory.js:13:13)
	at async /Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/out/main/treeDataProviders/dependenciesTree/dependenciesDataProvider.js:151:13
	at async /Users/-----/.vscode/extensions/jfrog.jfrog-vscode-extension-1.7.0/out/main/utils/scanUtils.js:22:13

I also get a result of 0 when running checkVenv.py with the virtual environment activated and a 1 if it's not activated. If there are log files, can you tell me where to find them so I can include them here?

Running checkVenv.py through a debugger, it seems that virtualenv_prefix is being set to None and venv_prefix is being set to '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8', which is not the project's activated virtual environment. The correct virtual environment is returned by sys.prefix:

(venv) laptop:test -----$ python
Python 3.8.2 (default, Aug 25 2020, 09:23:57) 
[Clang 12.0.0 (clang-1200.0.32.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.prefix)
/Users/-----/VS Code Projects/test/venv

I'm wondering if there might be a bug in isInVirtualEnv() or getPythonPath() in pypiUtils.ts since isInVirtualEnv() is obviously returning a false value given the following error message:
Please install and activate a virtual environment before running Xray scan. Then, install your Python project in that environment.

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

@ducoterra
Please make sure to activate your venv as follows:
1.
image
2.
image

Please let me know if it helped.
We'd also appreciate any other feedback about the extension and its instructions.

from jfrog-vscode-extension.

ducoterra avatar ducoterra commented on August 25, 2024

That's the issue, I do have my virtual environment activated like that. The xray plugin doesn't seem to recognize it.

from jfrog-vscode-extension.

ducoterra avatar ducoterra commented on August 25, 2024

Are there logs I can provide that would help identify the issue?

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

Thanks, @ducoterra.
To figure our whether the current Python project is running under Virtualenv, we run this script in the root folder of the project:

import sys

virtualenv_prefix = getattr(sys, "real_prefix", None)
venv_prefix = getattr(sys, "base_prefix", sys.prefix)
if virtualenv_prefix or venv_prefix != sys.prefix:
    exit(0)

exit(1)

For more information about this attitude, read here: https://stackoverflow.com/a/58026969/4233342

Can you please give it a try in your environment? You can try to run this as follows:

# Before activating the environment
python checkVenv.py
echo $?
# response code should be 1 because the Virtualenv is not activated

# Activate env
source venv/bin/activate
python checkVenv.py
echo $? 
# response code should be 0. What do you see here?

Can you please also provide more information about your environment? This information must include your operating system, virtual environment type and version. Are you using Anaconda virtualenv?

Looking forward to your feedback!

from jfrog-vscode-extension.

ducoterra avatar ducoterra commented on August 25, 2024

Thanks for the details! Here are my specs:

OS: macOS Catalina version 10.15.7 (19H2)
Python version: 3.8.3
Virtual environment type: might need some help answering this. It's not Anaconda. I ran python3 -m venv venv to create it.

I ran the script and got the expected output:

user@laptop project_dir % python3 checkVenv.py 
user@laptop project_dir % echo $?
1
user@laptop project_dir % source venv/bin/activate
(venv) user@laptop project_dir % python3 checkVenv.py 
(venv) user@laptop project_dir % echo $?
0

Appreciate the help.

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

@ducoterra,
Thanks for your inputs.

I created #75 to help investigating this issue further.

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

@ducoterra
We release JFrog VS-Code extension 1.5.2. In this version, when the extension fails to run checkVenv.py in the virtualenv, it prints the reason to the logs.

Looking forward to your feedback!

from jfrog-vscode-extension.

mlieberman85 avatar mlieberman85 commented on August 25, 2024

I'm also running into the same issue as @rderveloy and @ducoterra.

from jfrog-vscode-extension.

DrackThor avatar DrackThor commented on August 25, 2024

me too, exactly the same behavior!
I am using pyenv with pyenv-virtualenvwrapper with Python 3.9.1

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

@mlieberman85 @rderveloy @DrackThor
Thanks for your feedback.
We currently support only Virtualenv.

However, we plan to change, in the near future, the way we calculate the Python dependencies to better interact with the vscode-python extension. This extension contains all the information we need to properly build the dependency tree in all environments. 🚀
One direction we will start to investigate soon is to contribute an API that exposes the needed information.

We'll keep you updated once a better solution will be found.

from jfrog-vscode-extension.

yahavi avatar yahavi commented on August 25, 2024

@ducoterra @rderveloy @mlieberman85,
JFrog VS-Code extension 1.8.5 is released! On this version we retrieve the Python executable path in a better way - see #127.
Feel free to upgrade - we'd appreciate your feedback on that.

@DrackThor - currently only Virtualenv is supported by the extension.

from jfrog-vscode-extension.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.