File Browser does not work with smb-path
Describe the bug
I am using the File Browser with smb-path. This is a convenient way to access SMB shares and works by patching pathlib and installing a filter so that all Path:s starting with //<server-name>/share, e.g. //filshr33.us.dieterscompany.com/myShare are considered a SmbPath.
The problem is that the file Browser strips duplicate initial / from the path which means that a regular Path object is returned (instead of SmbPath), causing the File Browser to stop working when selecting any folder.
I think that I have located the problem to FileBrowserPlugin.tsx#L327. This in turn seems to be a fix fix: Double delimiter when navigating to root directory.
I am not sure if there is an interest to solve this as it might have other side effects and maybe smb-path isn't the most widely used library.
My current workaround is to instead use \\<server-name>\<share> which is also supported by smb-path. But this comes with several side effects as I am running on Linux.
Will you submit a PR?
- Yes
Environment
{
"marimo": "0.19.9",
"editable": false,
"location": "/home/XXXXX/.venv/lib/python3.12/site-packages/marimo",
"OS": "Linux",
"OS Version": "6.14.0-37-generic",
"Processor": "x86_64",
"Python Version": "3.12.3",
"Locale": "--",
"Binaries": {
"Browser": "144.0.7559.132",
"Node": "--"
},
"Dependencies": {
"click": "8.3.1",
"docutils": "0.22.4",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.10.1",
"narwhals": "2.15.0",
"packaging": "26.0",
"psutil": "7.2.1",
"pygments": "2.19.2",
"pymdown-extensions": "10.20",
"pyyaml": "6.0.3",
"starlette": "0.52.1",
"tomlkit": "0.14.0",
"typing-extensions": "4.15.0",
"uvicorn": "0.40.0",
"websockets": "16.0"
},
"Optional Dependencies": {
"loro": "1.10.3",
"openai": "2.17.0",
"pandas": "3.0.0",
"pytest": "8.4.2"
},
"Experimental Flags": {}
}Code to reproduce
Run below with:
TEST_USERNAME=<username> TEST_PASSWORD=<password> TEST_SHARE=<share> uvx marimo edit --sandbox filebrowser.pyE.g.
TEST_USERNAME=john.doe TEST_PASSWORD=secret TEST_SHARE="//filshr33.us.dieterscompany.com/myShare" uvx marimo edit --sandbox filebrowser.py# /// script
# requires-python = ">=3.11"
# dependencies = [
# "marimo>=0.19.9",
# "smb-path==0.7",
# ]
# ///
import marimo
__generated_with = "0.19.9"
app = marimo.App(width="medium")
with app.setup:
import marimo as mo
from pathlib import Path
import smb_path
import smbclient
import os
@app.cell
def _():
print(f"Using username:", os.environ["TEST_USERNAME"])
print(f"Using password:", os.environ["TEST_PASSWORD"])
print(f"Using SMB hare:", os.environ["TEST_SHARE"])
_client = smbclient.ClientConfig(username=os.environ["TEST_USERNAME"], password=os.environ["TEST_PASSWORD"])
return
@app.cell
def _():
data_file_browser = mo.ui.file_browser(
initial_path=os.environ["TEST_SHARE"],
)
mo.output.append(data_file_browser)
return
@app.cell
def _():
# Workaround, workd bad under Linux
data_file_browser2 = mo.ui.file_browser(
initial_path=os.environ["TEST_SHARE"].replace("/", "\\"),
)
mo.output.append(data_file_browser2)
return
if __name__ == "__main__":
app.run()Source: marimo-team/marimo