-
Notifications
You must be signed in to change notification settings - Fork 23
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
UnicodeEncodeError while using "mox init" #186
Comments
Hey! Thanks for pointing it out 👌 I suppose the env was activated since we see that it takes moccasin from your And it seems you are on Windows, I'll try to reproduce for science on my windows. No WSL ? I'll come back after testing |
I have tested, and I do have the same error by doing it on Windows with the same pattern as you. And yes, the following solution is working: def _write_file(path: Path, contents: str, overwrite: bool = False) -> None:
if not path.exists() or overwrite:
- with path.open("w") as fp:
+ with path.open("w", encoding="utf-8") as fp:
fp.write(contents) Just out of curiosity, Is there any motivation to install moccasin this way and not with You could then do @PatrickAlphaC is it something to fix for Windows users or is there something I missed? EDIT: maybe I'll need to double-check on Linux afterward |
WSL gave me strange network issues in the past so don't use it anymore on my main device. |
Yes, Wow thanks @s3bc40! Wondering... Are you interested in making that PR with the fix? I think maybe we should also add a I don't love supporting windows, since that opens up a can of worms, but you should be able to at least install! |
I am not a big fan of windows for coding too, aha. But I think I can just check if everything is fine with the current tests. And if I see something off, I'll dig into this and make specific tests (while learning how to do so). I'll make a PR when I'll reach something! |
Here is my PR: #191 I have added other fixes while trying to run mox on Windows, and test again on my Linux (feels way better!). After a few days trying to run the tests by installing moccasin locally on Windows, I think it will be a great idea to create a specific test suit for Windows. And the best would be to be capable of installing the repo on Windows and run the equivalent of what we already have on Linux or MacOs. But it will be a huge work, because it means to deal with the Windows permission system, which is kind of a nightmare to handle. Especially the Maybe with someone with more XP it would be smoother. But for now I have fixed some features that didn't run on Windows. |
…arser (#191) * fix: windows issues on mox cli command and utils argparser - `init.py`: windows error `(UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f40d')` when the param `encoding="utf-8" for `open` is not set - `compile.py`: windows does not support `fork` method for `multiprocessing.set_start_method()`, hence changed to "spawn" - `vars.py`: added general constant `IS_WINDOWS` for future use and avoid any duplicates - fixed utils CLI command running an error when no arguments passed + fixed some var typo * fix: format with ruff reorder import
This should be fixed now! |
i've installed moccasin in an isolated environment with uv
when i launch
mox init my_project
i get
in file .venv\Lib\site-packages\moccasin\commands\init.py, row 103, i changed
with path.open("w") as fp:
to
with path.open("w", encoding="utf-8") as fp:
and now the command works fine =)
The text was updated successfully, but these errors were encountered: