gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
32 stars 15 forks source link

Issues in docker and/or CI (env var USER) #240

Closed hetsko closed 1 year ago

hetsko commented 1 year ago

Hi.

An error is raised during import when trying to use omas in a docker container and/or gitlab CI pipeline, where the default user is root and traditional configurations (.bashrc, .profile) might be a bit different. The issue is the USER env variable, which is not set in these environments. It works with this workaround:

export USER=''
python -c 'import omas'

Proposed solution

The exception points to https://github.com/gafusion/omas/blob/master/omas/omas_utils.py#L869

I feel like this check could be replaced by a simpler one using only the UID (which is set in docker):

if os.name == 'nt' or os.environ['UID'] != os.stat(__file__).st_uid:

Although I have not gurantee that this is more correct and universal (will try to google), it feels like it could be.

Or just to be sure, using get() would also help

... or os.environ.get('UID') != ...
smithsp commented 1 year ago

@hetsko Can you put this in a Pull Request? Then it will be automatically tested.

hetsko commented 1 year ago

Sure, will try to get to it later today.

hetsko commented 1 year ago

@smithsp One week later, the PR #245 is here.