conda-forge / libignition-gazebo-feedstock

A conda-smithy repository for libignition-gazebo.
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Ignition Gazebo read and write the user home directory #31

Open traversaro opened 2 years ago

traversaro commented 2 years ago

See https://github.com/conda-forge/libignition-gazebo-feedstock/issues/27#issuecomment-952610940 . I have the feeling that this breaks for most users principle_of_least_astonishment, as I guess most users would expect that what happens in one conda environments remains in that conda environment.

traversaro commented 2 years ago

In particular, this means that if via a conda gazebo the configuration file or anything else that is saved in the user home is changed, this influence the apt installed version of gazebo.

traversaro commented 2 years ago

A possible strategy to solve this is to re-define HOME env variable in *nix and USERPROFILE on Windows (see https://github.com/ignitionrobotics/ign-common/blob/8ba9b71526b63193159adc577976949e83a089ee/include/ignition/common/Util.hh#L37 and https://github.com/ignitionrobotics/ign-common/pull/127) to point to a directory inside the environment, but I am not sure if this is even possible/desireable. Furthermore, I guess this needs to be discussed at conda-forge level.

diegoferigo commented 2 years ago

I fully agree on your comments. Maybe what we can do in the conda distribution is changing IGN_HOMEDIR to point to a custom environment variable, that can be defined per-conda-environment in the activation / deactivation scripts.

traversaro commented 2 years ago

A less invasive change is probably to patch ign-common to point to use a ignition-specific env variable, and just define that one to point to a directory in the conda environment.

traversaro commented 2 years ago

To check

I fully agree on your comments. Maybe what we can do in the conda distribution is changing IGN_HOMEDIR to point to a custom environment variable, that can be defined per-conda-environment in the activation / deactivation scripts.

* https://github.com/ignitionrobotics/ign-common/blob/ee5ba8e596e86e41dcec61847c3b6bdf0fa8c04a/include/ignition/common/Util.hh#L36-L40

* https://github.com/search?q=org%3Aignitionrobotics+IGN_HOMEDIR&type=code

It seems we had the same idea indipendently. Even if Gazebo does not follow XDG specs, I searched for the XDG env variables (see https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) in conda-forge organization to check if this was already discussed, but I could not find anything.

diegoferigo commented 2 years ago

It seems we had the same idea indipendently.

Yep, here below some more details :)

A less invasive change is probably to patch ign-common to point to use a ignition-specific env variable, and just define that one to point to a directory in the conda environment.

Yep, what I was proposing is something similar, but also giving the possibility to users to point to another folder (that could also be the original one in $HOME by re-exporting the environment variable.

In short:

  1. Change the macro defining #define IGN_HOMEDIR "IGN_HOME_DIR"
  2. Export an env var from activate sh/bat export IGN_HOME_DIR=${CONDA_PREFIX}/etc/ignition (or similar) so that there is a default behavior well defined
  3. If a user wants to roll back to the default behavior sharing the folder among conda envs, they can export after the env creation with conda env the variable IGN_HOME_DIR=$HOME
traversaro commented 2 years ago

I opened https://github.com/conda-forge/conda-forge.github.io/issues/1539 to collect feedback from conda-forge. Given that apparently conda environments can also be shared across users (see https://github.com/conda/conda/issues/1329) and $CONDA_PREFIX is kind of replicating a normal FHS structure, I wonder if IGN_HOME_DIR in conda context should simply point to $CONDA_PREFIX/home/$USER