Closed e2jk closed 3 years ago
[Ignore this comment, is not the cause of this issue]
Well, actually re-reading the traceback, I'm suprised by seeing this line (shown after the second call from the top in the traceback):
│ [Errno 2] No such file or directory: 'C:\\Users\\<username>\\.local\\bin\\cookietemple.exe\\__main__.py' │
This cookietemple.exe
is the executable that pipx
created when installing cookietemple. It looks like cookietemple creates a path to its __main__.py
file by assuming it is in a folder down the main folder.
The __main__.py
file is to be found in the virtual environment folder that pipx created when installing cookietemple, which in my case is:
"C:\Users\<username>\.local\pipx\venvs\cookietemple\Lib\site-packages\cookietemple\__main__.py"
I have a bit of trouble understanding the rest of the Traceback, am I correct in believing that the UnicodeDecodeError is triggered because the file path is empty or undefined? If that's the case, it would be helpful to rename this issue in "New project creation fails on Windows when installed with pipx (UnicodeDecodeError when Running lint checks)"
[Ignore this comment, is not the cause of this issue]
Again, maybe just ignore the previous comment. Although the traceback complains about the file not existing, the immediate next entry in the traceback is for the actual __main__.py
file, so it looks like that bit is not the cause of the issue:
[SNIP]
│ [Errno 2] No such file or directory: 'C:\\Users\\<username>\\.local\\bin\\cookietemple.exe\\__main__.py' │
│ │
│ C:\Users\<username>\.local\pipx\venvs\cookietemple\lib\site-packages\cookietemple\__main__.py:53 in main
[SNIP]
OK, getting a bit further... By adding a poor man's debug statement print("XX", path)
at C:\Users\<username>\.local\pipx\venvs\cookietemple\lib\site-packages\cookietemple\lint\template_linter.py:237
(one of the lines involved in the Traceback) I get the following output just before the Exception being thrown:
XX timelog_tracker/__init__.py
XX .cookietemple.yml
XX docs/conf.py
XX pyproject.toml
XX .github/release-drafter.yml
So that last file must be what is causing all this trouble. And indeed, when opening the file in Notepad++, I see it contains some of the nowadays funky emoticons:
Looks like (at least on my machine [Windows]?) these funky characters are not of the taste of the character encoding...
OK, that was it.
By removing the 4 emoticons highlighted in the previous post from the template file "C:\Users\<username>\.local\pipx\venvs\cookietemple\Lib\site-packages\cookietemple\create\templates\common_files\{{cookiecutter.commonName}}\.github\release-drafter.yml"
, the process passed that section of the code succesfully.
I suppose these emoticons work for some people, but I'd be inclined to submit a PR to remove them from the template. Any opposition to that?
(unfortunately, a new Traceback is triggered because of the autopep8
command not being recognized, I'll open a separate issue #750 for that...)
Quoting @Zethson's comment from the linked PR (which I just closed):
Thank you for the PR. We are rather reluctant to remove this. Is it possible to install the missing support for these characters in W10 enterprise? If yes, I would prefer to add this to the installations instructions. Honestly, I am confused why these characters are not supported to begin with. We cannot be the first people to use these characters on Windows. They should be rather common.
Searching a bit around (for instance here) it seems that the issue is with Windows's default characterset Windows-1252 not having these extended characters. Or you could see the issue differently, that Windows doesn't use Unicode/UTF-8 by default (as Linux and MacOS do).
Maybe a solution can be found in being explicit about which characterset to use when opening these files for linting, something like adding an explicit , encoding='utf-8'
to the open
command when inspecting these files?
Maybe a solution can be found in being explicit about which characterset to use when opening these files for linting, something like adding an explicit
, encoding='utf-8'
to theopen
command when inspecting these files?
Perfect, yes. Let's do this.
[EDIT] Root cause found, see this post and the question if a PR would be accepted for this topic.
Associated Template/Command/Core
C:\Users\<username>\Documents\devel>cookietemple --verbose create
(on Windows 10)After bypassing issue #748 (by commenting out the call to
shutil.rmtree
in filecookietemple\lib\site-packages\cookietemple\create\template_creator.py:354
), when creating a new project (first time using cookietemple, which I installed usingpipx
), a Traceback is triggered when running linting function: check_version_consistent. Namely:UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 230: character maps to <undefined>
It might be interesting to note that my system's language is set to French (wich accents etc.), although it doesn't seem that there are accents involved in the different paths used, as I'm creating the project in path
C:\Users\<username>\Documents\devel
.To Reproduce
Steps to reproduce the behavior:
create
Full `--verbose` output of the command (Click to expand)
``` C:\Users\Expected behavior
I would have expected the program to finish without throwing an Exception, and upload the project to GitHub, register on PyPI (or whatever cookietemple is expected to do - as mentioned, this is first time I'm using it)
System:
pipx
)pipx
Additional context
Please ask if any other detail would be needed. In the meantime I'll start with the files created in the folder, and will handle the project creation manually on GitHub.