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

[bug] - use conan client on windows, conan new throw a utf-8 error. #17947

Closed
blazewater-gmail opened this issue Mar 12, 2025 · 8 comments
Closed
Assignees
Labels
stage: triaging staled The issue has been inactive for a while and will be closed soon

Comments

@blazewater-gmail
Copy link

Describe the bug

OS: Windows 10
I only add one built c++ library into repo, tell me utf-8 error.

 /d/develop/installed $ conan new QWindowKit-Qt673 -d name=QWindowKit -d version=1.0
ERROR: Traceback (most recent call last):
  File "D:\Python\Python310\lib\site-packages\conan\cli\cli.py", line 307, in main
    cli.run(args)
  File "D:\Python\Python310\lib\site-packages\conan\cli\cli.py", line 192, in run
    command.run(self._conan_api, args[0][1:])
  File "D:\Python\Python310\lib\site-packages\conan\cli\command.py", line 179, in run
    info = self._method(conan_api, parser, *args)
  File "D:\Python\Python310\lib\site-packages\conan\cli\commands\new.py", line 48, in new
    files = conan_api.new.get_template(args.template)  # First priority: user folder
  File "D:\Python\Python310\lib\site-packages\conan\api\subapi\new.py", line 61, in get_template
    return self._read_files(template_folder)
  File "D:\Python\Python310\lib\site-packages\conan\api\subapi\new.py", line 89, in _read_files
    template_files[rel_f] = load(path)
  File "D:\Python\Python310\lib\site-packages\conans\util\files.py", line 143, in load
    tmp = handle.read()
  File "D:\Python\Python310\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

ERROR: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

How to reproduce it

No response

@memsharded memsharded self-assigned this Mar 12, 2025
@memsharded
Copy link
Member

Hi @blazewater-gmail

Thanks for your feedback.

Can you please try with conan new cmake_lib -d name=QWindowKit -d version=1.0 instead?

It could be that your custom template QWindowKit-Qt673 are not utf-8 files. Please check that and save them in utf-8 if not, and let us know.

@memsharded
Copy link
Member

Hi @blazewater-gmail

Did you check your templates, if they were encoded with utf-8?

@memsharded memsharded added the staled The issue has been inactive for a while and will be closed soon label Mar 17, 2025
@blazewater-gmail
Copy link
Author

blazewater-gmail commented Mar 19, 2025

Hi @blazewater-gmail

Did you check your templates, if they were encoded with utf-8?

thanks for your reply.
Sorry for the late reply.

yes, there utf-8 files in the directory of built library QWindowKit-Qt673

I build the library QWindowKit-Qt673,
and I want to use conan to store the library of this building,
so I want to add these files(contains CMake target file, header file, binary dll file, etc..), the text file is utf-8 encoding.
and when I using command to add these files to conan, the error appeared.
maybe I have made some mistakes or misunderstanding in conan usage?

My original target is using conan as binary library tracking and storing server,
I will build library using other automated tools, and upload updated binary library into conan, I think conan will track version changing record(is it right?)
so, when I build ok and upload to conan ok,
I will notify the team to update theirs' local library from conan, to sync library updating.

@memsharded
Copy link
Member

Thanks for your feedback.

I might be missing something.

The conan new template system is just using some simple text files as templates, not binary files or anything like that.
Something similar to what the conan new cmake_lib built-in template does.
User templates shouldn't contain binary files in the general case.

Conan can indeed build, generate, store and upload binaries, use those binaries later, and more.
But that is not connected to the conan new command, which is a simple onboarding tool, to use some common patterns for conanfiles within an organization.

Maybe you can share your QWindowKit-Qt673 template files? Put them in a zip folder and attach them here, so we can inspect them?

@blazewater-gmail
Copy link
Author

yes, it's my build for specified qt version and QWindowKit open source version
and indeed I want to manage these version relations in compiled library.
here u r.

QWindowKit-Qt673.zip

@memsharded
Copy link
Member

But that zip contains binaries.
That is not the intended usage of conan new templates at all.
The conan new templates are to create some general scaffolding to kick-off new projects, but those should be like common, repeated packages recipes. Take the conan new cmake_lib example, it doesn't contain binaries, it just create some example conanfile.py with some example C++ code to play with it.

It seems that what you want to do is to put those files in a repository and to do a conan export-pkg + conan upload to your repository instead. But no conan new should be involved there at all.

@yanlusu
Copy link

yanlusu commented Mar 20, 2025

It seems that what you want to do is to put those files in a repository and to do a conan export-pkg + conan upload to your repository instead. But no conan new should be involved there at all.

yes, that's right.
I'll read document of conan carefully.
Thank you for your patience

@memsharded
Copy link
Member

Ok, I am then closing this ticket as not-a-bug, but as a question. The conan new command templates is not intended for this use case.

If you have new questions about conan export-pkg or any other topic, you can create new tickets for those. Thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: triaging staled The issue has been inactive for a while and will be closed soon
Projects
None yet
Development

No branches or pull requests

3 participants