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

make wenv work with a read-only prefix - fallback to $HOME/.cache/wenv #22

Open
milahu opened this issue Apr 16, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@milahu
Copy link

milahu commented Apr 16, 2024

by default, wenv fails with a read-only prefix

>>> import zugbruecke.ctypes as ctypes
OSError: [Errno 30] Read-only file system: '/nix/store/12hx5iv7v4jw64p4fwzx2cjwpdzh2gpf-python3-3.11.7-env/share/wenv'

wenv/_core/env.py

    def ensure(self):
        self.setup_wineprefix()
    def setup_wineprefix(self, overwrite: bool = False):
        os.makedirs(
            self._p["wineprefix"]
        )

wenv/_core/config.py

        if key == "prefix":
            install_location = os.path.abspath(__file__)
            if install_location.startswith(
                site.USER_BASE
            ):  # Hacky way of looking for a user installation
                return site.USER_BASE
            return sys.prefix
        if key == "wineprefix":
            return os.path.join(self["prefix"], "share", "wenv", self["arch"])

workaround: set env WENV_WINEPREFIX=/some/where/else
or WENV_PREFIX=/some/where/else

import os
os.environ["WENV_PREFIX"] = os.environ["HOME"] + "/.cache/wenv"
import zugbruecke.ctypes as ctypes

expected: if the default wineprefix is read-only
then fallback to $HOME/.cache/wenv/wine via platformdirs

similar #14

@s-m-e s-m-e added the enhancement New feature or request label Apr 16, 2024
@s-m-e
Copy link
Member

s-m-e commented Apr 16, 2024

Having this kind of fallback is certainly a good idea. Added to my todo - though PR welcome ;)

@milahu
Copy link
Author

milahu commented Apr 16, 2024

two seconds ^^

ideally i want to setup the wine env only once in the read-only package store
so im running wenv init as part of the build process
just the default wineprefix is wrong, its based on the python interpreter location...

@milahu
Copy link
Author

milahu commented Apr 17, 2024

related issue:

this will not work with unpatched wine

wine/libs/wine/config.c

    if (st.st_uid != getuid()) fatal_error( "%s is not owned by you\n", config_dir );

wine complains about the ownership of WINEPREFIX

$ ./result/bin/wenv python
wine: '/nix/store/mcbrxyi2q7kksyrxm7px9l0ik3rxv94h-wenv-0.5.1/share/wenv/win32' is not owned by you

WINEPREFIX is not owned by you

i found many discussions on this problem
but no solution to make wine ignore the ownership
workarounds: sudo, chown, symlinks, bind mount, LD_PRELOAD, ...


but this issue remains:

if the default WENV_PREFIX is read-only
then wenv should fallback to $HOME/.cache/wenv

ideally the "cache" config should be a list of paths
for reading from the cache, all cache paths are used
for writing to the cache, the first writable cache path is used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants