Skip to content

Update helpers.py#299

Open
CH-GAGANRAJ wants to merge 1 commit into
rtCamp:developfrom
CH-GAGANRAJ:Fix-windows-grp-import
Open

Update helpers.py#299
CH-GAGANRAJ wants to merge 1 commit into
rtCamp:developfrom
CH-GAGANRAJ:Fix-windows-grp-import

Conversation

@CH-GAGANRAJ

Copy link
Copy Markdown

Fix : Does not work on Windows as there is a dependency on grp #289

Fix: Skip grp import on Windows to enable cross-platform CLI usage

PR Description:

This patch improves cross-platform compatibility by conditionally importing the Unix-only grp module in helpers.py. On Windows systems, the CLI previously failed due to ImportError. This fix:

  • Adds a platform check to safely skip grp import on Windows
  • Returns an empty dictionary from get_unix_groups() when grp is unavailable
  • Warns users via richprint.warn that Unix group info is not available on Windows

This allows the CLI to run natively on Windows without crashing, while preserving full functionality on Unix-based systems.

Let me know if you'd prefer a fallback behavior or stricter handling. Happy to iterate!

@meichthys

Copy link
Copy Markdown

Hey @CH-GAGANRAJ this looks too good to be true! Thanks for making the effort to fix this!

When i try it (on Windows 11) Iget the following:

PS C:\Users\username> pipx install git+https://github.com/CH-GAGANRAJ/Frappe-Manager.git@Fix-windows-grp-import
  installed package frappe-manager 0.18.0, installed using Python 3.13.3
  These apps are now globally available
    - fm.exe
done! ✨ 🌟 ✨
PS C:\Users\username> fm
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\username\.local\bin\fm.exe\__main__.py", line 2, in <module>
    from frappe_manager.main import cli_entrypoint
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\main.py", line 8, in <module>
    from frappe_manager.commands import app
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\commands.py", line 12, in <module>
    from frappe_manager.site_manager.SiteManager import BenchesManager
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\site_manager\SiteManager.py", line 7, in <module>
    from frappe_manager.site_manager.site import Bench
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\site_manager\site.py", line 22, in <module>
    from frappe_manager.site_manager.bench_config import BenchConfig, FMBenchEnvType
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\site_manager\bench_config.py", line 36, in <module>
    class BenchConfig(BaseModel):
    ...<182 lines>...
            return template_inputs
  File "C:\Users\username\pipx\venvs\frappe-manager\Lib\site-packages\frappe_manager\site_manager\bench_config.py", line 49, in BenchConfig
    userid: int = Field(default_factory=os.getuid, description="The user ID of the current process")
                                        ^^^^^^^^^
AttributeError: module 'os' has no attribute 'getuid'. Did you mean: 'getpid'?

@meichthys

meichthys commented Oct 2, 2025

Copy link
Copy Markdown

I played around with this a bit and it looks like there are MANY more changes needed to get things working in windows.
Using ai i was able to get the fm command working and the global services, but creating a site was still failing all over the place.

@CH-GAGANRAJ

Copy link
Copy Markdown
Author

Thanks for testing this on Windows 11, @meichthys! I appreciate the feedback.
Just to clarify - this PR was specifically meant to address issue #289 related to helpers.py only. It sounds like there are additional Windows compatibility issues elsewhere in the codebase that are beyond the scope of this particular fix.

You're right that there are likely many more changes needed for full Windows support - this PR just tackles one specific piece of that puzzle.
Would it be helpful to:

Create separate issues for the other Windows compatibility problems you've found?
Keep this PR focused on the helpers.py fixes for #289?

Let me know if the changes I made in helpers.py specifically are causing any issues, and I'm happy to address those!

@meichthys

Copy link
Copy Markdown

It may be helpful to track all of the issues, however, since this would be such a large undertaking, I think we would need input from the maintainers first since none of these fixes accomplish anything until the whole windows compatibility issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants