Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The problem is with root vs all other users is that it’s $HOME is literally /root/ while other users have their $HOME directory in /home/username/

~ is a BASH tilde expansion for $HOME. So in this case Cloud Run would have been looking at /home/root/.cache/ which doesn’t exist (/root/.cache/ is what was being built), whereas another user would have /home/username/.cache/ and run as expected.

PS. I was initially going to call ~ an alias, but I checked myself and found it’s actually considered a BASH tilde expansion. While ~ alone operates as an alias, I learned there are all kinds of other uses for variations of ~ which hopefully someone will find useful:

http://www.gnu.org/software/bash/manual/html_node/Tilde-Expa...



>So in this case Cloud Run would have been looking at /home/root/.cache/

Firstly, the article says that Cloud Run is setting $HOME to /home. Which means Huggingface would've been looking at /home/.cache, not /home/root/.cache. $HOME is not a base path to which the username is appended to get the homedir. It's the homedir itself.

I also assume this isn't the article author using a shorthand (ie writing "/home" when they mean "/home/someuser"), because the SO post they link to also says the same thing. So, as busted as it is, it does sound like Cloud Run is setting HOME to /home.

Secondly, and more importantly, my point is that if Cloud Run is setting HOME=/root at container build time and HOME=/home at container runtime, then any path rooted to $HOME is going to be different at build time vs runtime, regardless of what user the process in the container is running as.

    $ docker run -it --rm -e HOME=/foo debian:10-slim sh -c 'echo $HOME/.cache'

    /foo/.cache

    $ docker run -it --rm -e HOME=/bar --user 1000 debian:10-slim sh -c 'echo $HOME/.cache'

    /bar/.cache
So as good as it is to not run containerized processes as root, I don't think it makes any difference to this particlar issue.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: