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

Cannot save on Windows if file path contains "&" character #3761

Open
transistorgrab opened this issue Feb 12, 2025 · 3 comments · Fixed by #3768
Open

Cannot save on Windows if file path contains "&" character #3761

transistorgrab opened this issue Feb 12, 2025 · 3 comments · Fixed by #3768
Labels
bug Something isn't working platform:windows

Comments

@transistorgrab
Copy link

transistorgrab commented Feb 12, 2025

Describe the bug

I tried to create a notebook in a folder that contains a "&" character which is obviously allowed in Windows.
The folder name is displayed as D:\Temp\test space\test&space\test_ma.py in marimo.
Windows shows it as D:\Temp\test space\test&space\test_ma.py

Marimo displays an error message:
"Failed to save" "Save handler cannot rename files."
Image
Console output shows 'charmap' codec can't encode character '\x85' in position 84: character maps to <undefined>

marimo works when there is no "&" in the folder path.

I cannot rename the folder because this is on a shared drive where other people also have access.

"marimo env" also crashed in the console.
starting a new console gave the desired output

Environment

Windows 10, Python 3.12, marimo 0.11.2
{
  "marimo": "0.11.2",
  "OS": "Windows",
  "OS Version": "10",
  "Processor": "Intel64 Family 6 Model 154 Stepping 4, GenuineIntel",
  "Python Version": "3.12.2",
  "Binaries": {
    "Browser": "--",
    "Node": "--"
  },
  "Dependencies": {
    "click": "8.1.7",
    "docutils": "0.21.2",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.1",
    "markdown": "3.7",
    "narwhals": "1.23.0",
    "packaging": "24.0",
    "psutil": "5.9.8",
    "pygments": "2.17.2",
    "pymdown-extensions": "10.14",
    "pyyaml": "6.0.1",
    "ruff": "0.9.2",
    "starlette": "0.45.2",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.11.0",
    "uvicorn": "0.34.0",
    "websockets": "14.2"
  },
  "Optional Dependencies": {
    "pandas": "2.2.1"
  },
  "Experimental Flags": {}
}

Code to reproduce

import pandas

@transistorgrab transistorgrab added the bug Something isn't working label Feb 12, 2025
devin-ai-integration bot added a commit that referenced this issue Feb 12, 2025
mscolnick added a commit that referenced this issue Feb 12, 2025
Fix Windows path encoding for special characters (#3761)

This PR fixes an issue where marimo fails to save files on Windows when
the file path contains special characters like '&'.

Changes:
- Updated `_rename_file` in file_manager.py to use pathlib.Path for
cross-platform path handling
- Added Windows-specific test to verify special character handling

Test Results:
- All existing tests pass (20 passed)
- New Windows-specific test added (skipped on non-Windows platforms)
- Manual verification on Windows required for special character handling

Fixes #3761

Link to Devin run:
https://app.devin.ai/sessions/6509c2c682564aa9910483478a642ed5
Requested by: Myles

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Myles Scolnick <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@transistorgrab
Copy link
Author

Hi @mscolnick
I updated marimo on my machine today to 0.11.6 with pip install --upgrade marimo.
However, I still see exactly this same faulty behaviour.
When I read this correctly it should have been fixed with 0.11.3 already?
Also, I again only get errors when trying to run marimo env

D:\>marimo env
Exception in thread Thread-2 (_readerthread):
Traceback (most recent call last):
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1597, in _readerthread
    buffer.append(fh.read())
                  ^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 41: character maps to <undefined>
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Scripts\marimo.exe\__main__.py", line 7, in <module>
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\marimo\_cli\cli.py", line 788, in env
    click.echo(json.dumps(get_system_info(), indent=2))
                          ^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\marimo\_cli\envinfo.py", line 61, in get_system_info
    "Browser": get_chrome_version() or "--",
               ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\marimo\_utils\health.py", line 129, in get_chrome_version
    return get_chrome_version_windows()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\redacted\AppData\Local\Programs\Python\Python312\Lib\site-packages\marimo\_utils\health.py", line 98, in get_chrome_version_windows
    return stdout.strip().split()[-1]
           ~~~~~~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

@mscolnick mscolnick reopened this Feb 18, 2025
@mscolnick
Copy link
Contributor

I re-opened the issue. Apologies, we have trouble testing on windows. Any chance you'd be able to help debug / write a failing tests for us, so that we can fix it?

@mscolnick
Copy link
Contributor

For the env check, this PR should fix it: #3841

mscolnick added a commit that referenced this issue Feb 18, 2025
Windows only. Problem posted in #3761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform:windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants