I have the following script in a sh file running in the host:
printf '\n\n=== Installing asdf ...\n\n'
docker container exec "$CONTAINER_NAME" sh -c 'git clone https://github.com/asdf-vm/asdf.git /root/.asdf --branch v0.10.2'
docker container exec "$CONTAINER_NAME" sh -c 'echo ''. /root/.asdf/asdf.sh'' >> /root/.bashrc'
docker container exec "$CONTAINER_NAME" sh -c 'echo ''. /root/.asdf/completions/asdf.bash'' >> /root/.bashrc'
printf '\n\n=== Installing node/npm using asdf ...\n\n'
NODEJS_VERSION='17.9.0'
docker container exec "$CONTAINER_NAME" sh -c 'asdf plugin add nodejs'
docker container exec "$CONTAINER_NAME" sh -c "asdf install nodejs $NODEJS_VERSION"
docker container exec "$CONTAINER_NAME" sh -c "asdf global nodejs $NODEJS_VERSION"
When asdf plugin add nodejs
line is executed I get the following error:
sh: 1: asdf: not found
The whole issue is happening because $PATH
is not being updated after the installation of asdf
. I tried:
- to reload .bashrc/.profile after installing
asdf
docker container exec "$CONTAINER_NAME" sh -c '. /root/.bashrc'
- to restart the container:
docker "$CONTAINER_NAME" restart
The (not so) weird thing is when I get into the container I can use asdf because, as expected, $PATH
contains the path to asdf
folders.
Does anybody knows what I am missing here?