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

~Unable to initialize cdktf project in pycharm with venv activated #705

Open
maciak-g opened this issue May 14, 2021 · 8 comments
Open

~Unable to initialize cdktf project in pycharm with venv activated #705

maciak-g opened this issue May 14, 2021 · 8 comments
Labels
bug Something isn't working language/python priority/awaiting-more-evidence Lowest priority. Unlikely to be worked on unless/until it gets a lot more upvotes.

Comments

@maciak-g
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

0.3.0

Affected Resource(s)

project initialize

Debug Output

https://gist.github.com/maciak-g/2435e8595ca23c33c374c0c774a857ec

Expected Behavior

Project should be initialized

Actual Behavior

Error message that pip cannot perform --user install.

Steps to Reproduce

Install pycharm, create project with pycharm, initialize venv environment in the project.

Important Factoids

I want to initialize project from the level of pycharm not custom initialization tool and install pip packages within initialized python virtual environment. The second case is I want to add this library to existing project where I have already prepared configuration for objects I will provision to cloud. I am puzzled why there are no alternative instructions to setup project manually or some more options to direct how packages should be installed.

References

  • #0000
@maciak-g maciak-g added bug Something isn't working new Un-triaged issue labels May 14, 2021
@jsteinich
Copy link
Collaborator

There may be a conflict between pip and your virtualenv. There are 2 separate templates, perhaps trying the python one would work better with your setup.

When it comes to manual setup, there's really only a couple steps.

  1. Create a cdktf.json file
  2. Install the cdktf package
  3. Optionally install prebuilt providers

@maciak-g
Copy link
Author

But could you check this hardcoded --user parameter in python-pip template ? For example as I have found on stackoverflow it is not needed when using venv, so forcing it doesn't have sense:
https://stackoverflow.com/questions/30604952/pip-default-behavior-conflicts-with-virtualenv

@jsteinich
Copy link
Collaborator

I think right now the python-pip template is assuming you aren't using a virtual environment while the python template creates one for you.

@cmclaughlin Do you have any thoughts on if it makes sense for the pip version to better support virtual environments?

@danieldreier danieldreier added language/python v0.3 priority/awaiting-more-evidence Lowest priority. Unlikely to be worked on unless/until it gets a lot more upvotes. and removed new Un-triaged issue labels Jul 2, 2021
@tl24
Copy link
Contributor

tl24 commented Aug 13, 2021

I ran into this as well. I couldn't make sense from the docs whether --user is the default or not, but you could detect whether you're in a virtual environment by checking to see if the VIRTUAL_ENV environment variable is set and not specify the --user flag if you are.

@jsteinich
Copy link
Collaborator

@tl24 that sounds like a reasonable solution. Would you be interested in creating a PR that does just that?

@tl24
Copy link
Contributor

tl24 commented Aug 17, 2021

Sure I can do that

@tl24
Copy link
Contributor

tl24 commented Aug 17, 2021

FYI I ran into an issue trying to test. There is a check in packages/cdktf-cli/bin/cmds/helper/init.ts that won't let you run with version 0.0.0. I'm not sure how one is supposed to test locally with that check. I had to comment it out temporarily.

@ansgarm
Copy link
Member

ansgarm commented Aug 17, 2021

I'm not sure how one is supposed to test locally with that check

You can build the cdktf package and specify it via --dist or CDKTF_DIST. I usually use the former with the init command. It is mentioned here, but please file an issue if something was left unclear and we can improve the docs there 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language/python priority/awaiting-more-evidence Lowest priority. Unlikely to be worked on unless/until it gets a lot more upvotes.
Projects
None yet
Development

No branches or pull requests

6 participants