Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common-utils overwrites .zshrc coming from image built with common-utils already #1035

Closed
AliOsm opened this issue Jul 10, 2024 · 18 comments
Closed
Assignees

Comments

@AliOsm
Copy link

AliOsm commented Jul 10, 2024

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?

@AliOsm
Copy link
Author

AliOsm commented Jul 10, 2024

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.

@AliOsm
Copy link
Author

AliOsm commented Jul 10, 2024

Specifically, this line overwrites the .zshrc file.

@AliOsm
Copy link
Author

AliOsm commented Jul 10, 2024

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 -)"

@samruddhikhandale
Copy link
Member

Hi 👋

Thanks for reporting!

@gauravsaini04 / @prathameshzarkar9 Can either of you look into fixing the bug?

@prathameshzarkar9
Copy link
Contributor

Hi @samruddhikhandale ,

I have created a PR to fix this issue: PR 1069
Kindly review the same

@prathameshzarkar9
Copy link
Contributor

Hi @samruddhikhandale ,
PR is updated and the test cases in the pipeline are now succeed. Kindly review the PR once.

@samruddhikhandale
Copy link
Member

Closing as fixed with #1069. Feel free to reopen if needed, thanks!

@Mark-J-Lawrence
Copy link

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.

@samruddhikhandale
Copy link
Member

Thanks for letting us know, I have reverted the changes. See #1094

@prathameshzarkar9 Can you take a look at the issue and merge the changes with the fix?

@prathameshzarkar9
Copy link
Contributor

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.?

@prathameshzarkar9
Copy link
Contributor

Hi @samruddhikhandale ,
I have created new PR #1111 to fix this issue.
kindly review the same

@Mark-J-Lawrence
Copy link

@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"
}

@Mark-J-Lawrence
Copy link

@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

@prathameshzarkar9
Copy link
Contributor

Hi @Mark-J-Lawrence ,
Can you provide Dockerfile also just to verify the impact.

@Mark-J-Lawrence
Copy link

@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

@samruddhikhandale
Copy link
Member

@prathameshzarkar9 Can you look at the latest details and continue investigation?

@prathameshzarkar9
Copy link
Contributor

Hi @samruddhikhandale ,
Latest review comments addressed. kindly review it once.

@samruddhikhandale
Copy link
Member

Completed with #1111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants