agkozak / zsh-z

Jump quickly to directories that you have visited "frecently." A native Zsh port of z.sh with added features.
MIT License
2.02k stars 76 forks source link

zsh-z fails to work if `.z` is mapped to docker host file #86

Open fzyzcjy opened 8 months ago

fzyzcjy commented 8 months ago

Hi thanks for the library! I want to use it in docker containers (indeed https://github.com/jupyter/docker-stacks). It works pretty well, until I want to keep the history between container re-creations. To do so, I add a volume mount from my host to the container, e.g. the following docker compose file:

    volumes:
      - /home/tom/my_container_z:/home/jovyan/.z

However, zsh-z fails to work implicitly now. The .z is also always empty.

I guess it may because file locking mechanism etc. Is there any way to workaround it?

agkozak commented 8 months ago

I'll probably want to try out doing exactly what you're doing to see if I can detect what's going wrong. If you give me a couple of days, I should have time.

fzyzcjy commented 8 months ago

Thank you very much and take your time!

More detailed reproduction steps:

Here is my Dockerfile (omitting unrelated parts):

# Or use jupyter's docker-stacks directly; This one just adds more python packages and gpu support etc
FROM cschranz/gpu-jupyter:v1.6_cuda-12.0_ubuntu-22.04

# ... other commands omitted ...

USER root
RUN set -eux ; \
    chsh -s $(which zsh) ; \
    sh -c "$(curl -fsSL https://install.ohmyz.sh/)"
USER ${NB_UID}

RUN set -eux ; sed -i 's/plugins=(git)/plugins=(git z)/g' /home/jovyan/.zshrc

docker-compose.yaml:

version: "3"

services:
  jupyter:
    build: ./jupyter
    ports:
      - '8888:8888'
    command: 'start-notebook.py --ServerApp.root_dir=/host_home'
    environment:
      SHELL: /bin/zsh
    volumes:
      - /home/tom/Main/Others/primary_docker/.zsh_history:/home/jovyan/.zsh_history
      - /home/tom/Main/Others/primary_docker/.z:/home/jovyan/.z
    # ... unrelated things