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

[CLI] init failed virtualenv for python should print errors in red or not print Welcome message #8720

Closed
rothgar opened this issue Jun 24, 2020 · 3 comments · Fixed by #8723
Assignees
Labels
feature-request A feature should be added or improved. in-progress This issue is being actively worked on. package/tools Related to AWS CDK Tools or CLI

Comments

@rothgar
Copy link

rothgar commented Jun 24, 2020

The Question

If I run cdk init --language python and I don't have python3-venv installed the Welcome message output scrolls the error messages off of the screen and are not obvious.

Error in the code references this command

print('Unable to create virtualenv automatically');

The output is very helpful but ultimately not noticeable because it scrolls by so fast and is immediately followed by # Welcome to your CDK Python project! which made me assume the command was successful or previous errors were not important.

Executing Creating virtualenv...                                                                                                                                                                                                                                        
The virtual environment was not created successfully because ensurepip is not                                                                                                                                                                                           
available.  On Debian/Ubuntu systems, you need to install the python3-venv                                                                                                                                                                                              
package using the following command.                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                        
    apt-get install python3-venv                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                        
You may need to use sudo with that command.  After installing the python3-venv                                                                                                                                                                                          
package, recreate your virtual environment.                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                        
Failing command: ['$PWD/cdk-test/.env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']                                                                                                                                       
                                                                                                                                                                                                                                                                        
Unable to create virtualenv automatically                                                                                                                                                                                                                               
Please run python3 -m venv .env!

Ideally (for me) if there was an error with the virtualenv the welcome message would not be printed so the last output would be the error and how to fix it.

Environment

  • CDK CLI Version: 1.46.0 (build 63860b2)
  • OS: Ubuntu 18.04.4
  • Language (Version): Python

Other information

I first ran into the problem running through the workshop when I was told to activate the virtualenv. It may also be helpful to update the workshop to point out if the .env/bin/activate file doesn't exist then something may have gone wrong and a user should try to install python3-venv and re-init the repo.

@rothgar rothgar added the needs-triage This issue or PR still needs to be triaged. label Jun 24, 2020
@MrArnoldPalmer MrArnoldPalmer added the package/tools Related to AWS CDK Tools or CLI label Jun 24, 2020
@MrArnoldPalmer
Copy link
Contributor

@shivlaks the error in the init template is definitely easily missed. Can we make the output red and move it down so its not gone when the command finishes?

@shivlaks
Copy link
Contributor

@MrArnoldPalmer @rothgar I moved the post installation steps towards the end so they'll be the last things you see when you init a template. Modified the messages to be warnings rather than errors, which would show up as yellow.

I'm not strongly opinionated that it must be yellow, but it feels reasonable given there are steps to reconcile and the project was still initialized. thoughts? feel free to comment on #8723 directly

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jun 25, 2020
@SomayaB SomayaB changed the title init: failed virtualenv for python should print errors in red or not print Welcome message [CLI] init failed virtualenv for python should print errors in red or not print Welcome message Jun 25, 2020
@SomayaB SomayaB added in-progress This issue is being actively worked on. feature-request A feature should be added or improved. labels Jun 25, 2020
@mergify mergify bot closed this as completed in #8723 Jun 25, 2020
mergify bot pushed a commit that referenced this issue Jun 25, 2020
…cdk init (#8723)

Modified initialization of git and post install steps to the end of the init process.
Changed the current messages to use `warning` which will display them in yellow
and updated guidance text.

Closes #8720

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@MrArnoldPalmer
Copy link
Contributor

Sounds good. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. in-progress This issue is being actively worked on. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants