Repository navigation
Description
Describe the bug
When running reflex init is get the following error.
(.venv) PS C:\Users\User\Documents\Ordi> reflex init
───────────────────────────────────────────── Initializing Ordi ─────────────────────────────────────────────
[10:07:34] Initializing the web directory. console.py:104
Get started with a template:
(0) blank (https://blank-template.reflex.run) - A minimal template
(1) dashboard (https://dashboard-new.reflex.run/) - A dashboard with tables and graphs
(2) sales (https://sales-new.reflex.run/) - An app to manage sales and customers
(3) ai_image_gen (https://ai-image-gen.reflex.run/) - An app to generate images using AI
(4) ci_template (https://cijob.reflex.run/) - A template for continuous integration
(5) api_admin_panel (https://api-admin-panel.reflex.run/) - An admin panel for an api.
(6) nba (https://nba-new.reflex.run/) - A data visualization app for NBA data.
(7) customer_data_app (https://customer-data-app.reflex.run/) - An app to manage customer data.
Which template would you like to use? (0): 2
[10:07:42] Initializing the app directory. console.py:104
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\User\Documents\Ordi.venv\Scripts\reflex.exe_main.py", line 7, in
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\typer\main.py", line 327, in call
raise e
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\typer\main.py", line 310, in call
return get_command(self)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\typer\core.py", line 723, in main
return _main(
^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\typer\core.py", line 193, in _main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\typer\main.py", line 693, in wrapper
return callback(**use_params)
^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\reflex.py", line 151, in init
_init(name, template, loglevel, ai)
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\reflex.py", line 112, in _init
prerequisites.initialize_app(app_name, template)
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\utils\prerequisites.py", line 1504, in initialize_app
create_config_init_app_from_remote_template(
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\utils\prerequisites.py", line 1434, in create_config_init_app_from_remote_template
initialize_app_directory(
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\utils\prerequisites.py", line 519, in initialize_app_directory
path_ops.find_replace(
File "c:\Users\User\Documents\Ordi.venv\Lib\site-packages\reflex\utils\path_ops.py", line 200, in find_replace
filepath.write_text(text)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib\pathlib.py", line 1048, in write_text
return f.write(data)
^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f60a' in position 1903: character maps to
To Reproduce
Steps to reproduce the behavior:
Create a new venv
install reflex
Expected behavior
I would expect it to say initialized and not return an error
Specifics (please complete the following information):
- Python Version: 3.12
- Pip: 24.2
- Reflex Version: 0.5.9
- OS: Win 11
Activity
picklelo commentedon Aug 20, 2024
Thanks for reporting. Does the issue happen if you try to initialize with another template (like the blank one)?
Marmaduke1st commentedon Sep 3, 2024
Good question, I'm not sure. Sorry for delay, I'll check and get back to you
samarth9201 commentedon Sep 3, 2024
The issue arises due to a UnicodeEncodeError when reflex init encounters a non-ASCII character. The solution could be to specify UTF-8 encoding in the
filepath.write_textfunction by addingencoding="utf-8"to handle all characters properly.