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

Stopping generation because post_gen_project hook script didn't exit successfully Hook script failed (exit status: 1) #9

Closed
LBrummer opened this issue Aug 24, 2020 · 6 comments

Comments

@LBrummer
Copy link

LBrummer commented Aug 24, 2020

Hi!
I tried using the template in the bash console in VS Code running in WSL (Ubuntu), but got the following error when execting the commmand cookiecutter https://github.com/at-gmbh/at-python-template:

Select package_manager:
1 - conda
2 - pip
Choose from 1, 2 [1]: 
Select use_notebooks:
1 - yes
2 - no
Choose from 1, 2 [1]: 1
Select use_docker:
1 - no
2 - yes
Choose from 1, 2 [1]: 1
Select create_cli:
1 - no
2 - yes
Choose from 1, 2 [1]: 1
Select config_file:
1 - yaml
2 - hocon
3 - none
Choose from 1, 2, 3 [1]: 1
Select code_formatter:
1 - none
2 - black
Choose from 1, 2 [1]: 2
Select editor_settings:
1 - none
2 - vscode
3 - pycharm
Choose from 1, 2, 3 [1]: 2
Traceback (most recent call last):
 File "/tmp/tmprob9p_0q.py", line 167, in <module>
   handle_editor_settings()
 File "/tmp/tmprob9p_0q.py", line 119, in handle_editor_settings
   _rename_files('.vscode__editor', '__editor', '')
 File "/tmp/tmprob9p_0q.py", line 141, in _rename_files
   path.rename(path.with_name(path.name.replace(old, new)))
 File "/home/lbr/miniconda3/envs/tshack/lib/python3.8/pathlib.py", line 1358, in rename
   self._accessor.rename(self, target)
PermissionError: [Errno 13] Permission denied: '.vscode__editor' -> '.vscode'
ERROR: Stopping generation because post_gen_project hook script didn't exit successfully
Hook script failed (exit status: 1)

I retried it with Select editor_setting:None and it worked. So this maybe a VS Code running in WSL problem. Not really very important because it works now but maybe you find the time to fix it or tell me what I did wrong. Thanks!

@klamann
Copy link
Contributor

klamann commented Aug 24, 2020

thanks for the report!

we do have an integration test for vscode that runs fine on linux and windows, so I suspect this might be related to WSL or running Miniconda inside WSL.

Do we have any WSL users here who are willing to investigate this further? @sbunzel @SimonCW maybe?
Also, it would be interesting to add a test running on WSL to our CI pipeline.

@klamann
Copy link
Contributor

klamann commented Aug 24, 2020

WSL seems to be available on Github Actions actions/runner-images#50 (comment)

@sbunzel
Copy link
Contributor

sbunzel commented Aug 24, 2020

Hi @LBrummer, thanks for reporting this. We definitely want to improve test coverage for as many combinations as possible, so this is really helpful!

I tried replicating this particular issue without success. Could you help me understand your setup a little better @LBrummer:

  • Does this issue also occur when you run cookiecutter from a fresh conda environment? I.e., when you run conda create -n cookiecutter-env, conda activate cookiecutter-env and conda install -c conda-forge cookiecutter before you set up the project.
  • If it still doesn't work, could you tell us a little bit more about your setup. Which user are you running this with? Do you use a different user to manage conda environments?

Thanks!

@LBrummer
Copy link
Author

LBrummer commented Aug 25, 2020

Hi @sbunzel ,
I used a new conda environment to execute the cookiecutter generation command. Not sure if I used conda or pip to install cookiecutter. My cookiecutter version is 1.7.2. WSL is Ubuntu 18.04. python==3.8.5. I used my standard user that I use for everything. cookiecutter does not work with sudo so that shouldn't be the problem.

I just retried it in the same environment and it is still not working.

However I created a new environment and there everything is worked using standard options and the vscode option. So maybe it was just a weird glitch?

(test) lbr@AT-NB-071:~/repos$ cookiecutter https://github.com/at-gmbh/at-python-template
You've downloaded /home/lbr/.cookiecutters/at-python-template before. Is it okay to delete and re-download it? [yes]: 
full_name [Jane Doe]: 
company_name []: 
email [[email protected]]: 
project_name [My Project]: 
project_slug [my-project]: 
module_name [my_project]: 
project_short_description [A short summary of the project]: 
Select package_manager:
1 - conda
2 - pip
Choose from 1, 2 [1]: 
Select use_notebooks:
1 - yes
2 - no
Choose from 1, 2 [1]: 
Select use_docker:
1 - no
2 - yes
Choose from 1, 2 [1]: 
Select create_cli:
1 - no
2 - yes
Choose from 1, 2 [1]: 
Select config_file:
1 - yaml
2 - hocon
3 - none
Choose from 1, 2, 3 [1]: 
Select code_formatter:
1 - none
2 - black
Choose from 1, 2 [1]: 
Select editor_settings:
1 - none
2 - vscode
3 - pycharm
Choose from 1, 2, 3 [1]: 2
Hey Jane Doe! Your project was successfully created at /home/lbr/repos/my-project. Have fun with it!

@klamann
Copy link
Contributor

klamann commented Aug 28, 2020

are there any actions that we can take to mitigate these kinds of issues or should we close this?

maybe add a troubleshooting section to the readme and mention that a fresh WSL and conda env can be helpful?

@sbunzel
Copy link
Contributor

sbunzel commented Aug 29, 2020

Hey @LBrummer, thanks for checking again and reporting back. Glad that it worked out eventually. I tried replicating again this by testing a few different setup options but was not successful. Please let us know if you happen to run into similar problems in the future and we'll investigate this further!

@klamann: I think we should close this for now. The most potent general-purpose troubleshooting tip seems to be "install cookiecutter in a fresh conda env" so far. Since that hint is part of #13 already, I would leave it at that for now. Adding WSL as a separate environment for our tests seems useful to me nevertheless. I have created a separate issue for that: #14

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

3 participants