`common-utils` overwrites `.zshrc` coming from image built with `common-utils` already
I'm using rails/ruby image, which already uses common-utils. But I want to override some options like making Zsh the default shell and install OhMyZsh. When I add:
"ghcr.io/devcontainers/features/common-utils:latest": {
"installOhMyZsh": true,
"configureZshAsDefaultShell": true
}
To my devcontainer.json, this common-utils usage overwrites the .zshrc coming from rails/ruby image, which should not happen based on this common-utils script.
Any thoughts why this could happen?
I think I found something, when I add common-utils as follows:
"ghcr.io/devcontainers/features/common-utils:latest": {
"installOhMyZsh": false,
"installOhMyZshConfig": false,
"configureZshAsDefaultShell": true
}
IT is not overwriting the .zshrc file, but enabling OhMyZsh stuff as follows:
"ghcr.io/devcontainers/features/common-utils:latest": {
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
}
Overwrites it. So, I think the bug lives in this snippet.
Specifically, this line overwrites the .zshrc file.
So, the issue is as follows: in rails/ruby feature, an rbenv initialization line is added to the .zshrc file (ref). When I enable OhMyZsh, .zshrc file changes to OhMyZsh template and the initialization line disappears, so I need to add the following to my post create script in my DevContainer setup to add the initialization again:
echo 'eval "$(rbenv init -)"' >> /home/vscode/.zshrc
eval "$(rbenv init -)"
Hi 👋
Thanks for reporting!
@gauravsaini04 / @prathameshzarkar9 Can either of you look into fixing the bug?
Hi @samruddhikhandale , PR is updated and the test cases in the pipeline are now succeed. Kindly review the PR once.
Closing as fixed with https://github.com/devcontainers/features/pull/1069. Feel free to reopen if needed, thanks!
I think the changes to resolve this has broken devcontainers using ghcr.io/devcontainers/features/node:1. node & npm are not found after building the container
I have had to specify ghcr.io/devcontainers/features/common-utils:2.4.5 to get it building with node & npm again.
Thanks for letting us know, I have reverted the changes. See https://github.com/devcontainers/features/pull/1094
@prathameshzarkar9 Can you take a look at the issue and merge the changes with the fix?
Hi @Mark-J-Lawrence ,
We tried to reproduce the scenario but it is not reproducing in our codespace. Can you help us and provide a .devcontainer configuration file content to check what base image you are using and other configuration attributes values to have exact match with your usecase so that we would be able to trobleshoot and find the exact root cause.?
Hi @samruddhikhandale , I have created new PR https://github.com/devcontainers/features/pull/1111 to fix this issue. kindly review the same
@prathameshzarkar9
{
"name": "cics-security-sdv-samples Container",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
"vsintellicode.java.completionsEnabled": false,
"vsintellicode.python.completionsEnabled": false,
"vsintellicode.sql.completionsEnabled": false,
"vsintellicode.typescript.completionsEnabled": false,
"vsintellicode.modify.editor.suggestSelection": "disabled",
"errorLens.onSave": true,
"errorLens.messageEnabled": true,
"versionlens.suggestions.showOnStartup": true,
"editor.formatOnSave": true,
"ansible.python.interpreterPath": "/usr/local/python/current/bin/python",
"pylint.interpreter": [
"/usr/local/python/current/bin/python"
],
"eslint.workingDirectories": [
"./docs",
"./lib"
],
"stylelint.validate": [
"css",
"scss"
],
"stylelint.configBasedir": "./docs"
},
"extensions": [
"dbaeumer.vscode-eslint",
"usernamehw.errorlens",
"igorsbitnev.error-gutters",
"wayou.vscode-todo-highlight",
"pflannery.vscode-versionlens",
"bierner.markdown-emoji",
"redhat.ansible",
"ms-python.flake8",
"gruntfuggly.todo-tree",
"ms-python.python",
"ms-python.pylint",
"stylelint.vscode-stylelint"
]
}
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/node:1": {
"version": "18"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12"
}
},
"forwardPorts": [
3000,
3001
],
"privileged": true,
"remoteUser": "root",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind",
"workspaceFolder": "/workspaces",
"postStartCommand": "git config --global --add safe.directory /workspaces; git config commit.gpgsign false",
"postAttachCommand": "/post_script/initialise_dev_container.sh"
}
@prathameshzarkar9 this is what's in the initialise_dev_container.sh file:
# Install approval bot dependencies
npm install
# Install docs dependencies
cd docs
npm install
cd ..
# Install Ansible tooling
pip install ansible==10.2.0 ansible-lint==24.7.0 --root-user-action=ignore
# Install ansible script dependencies
cd ansible-sdv-pipeline
pip install -r requirements.txt --root-user-action=ignore
Hi @Mark-J-Lawrence , Can you provide Dockerfile also just to verify the impact.
@prathameshzarkar9 sure....
FROM mcr.microsoft.com/devcontainers/base:jammy
RUN apt update
ENV LOG_LEVEL="trace"
EXPOSE 3000
EXPOSE 3001
COPY initialise_dev_container.sh /post_script/initialise_dev_container.sh
RUN mkdir -p /workspaces; \
chmod 755 /post_script/initialise_dev_container.sh
WORKDIR /workspaces
@prathameshzarkar9 Can you look at the latest details and continue investigation?
Hi @samruddhikhandale , Latest review comments addressed. kindly review it once.
Completed with https://github.com/devcontainers/features/pull/1111