devcontainers / features

A collection of Dev Container Features managed by Dev Container spec maintainers. See https://github.com/devcontainers/feature-starter to publish your own
https://containers.dev/features
MIT License
853 stars 343 forks source link

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

Open AliOsm opened 1 month ago

AliOsm commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

Specifically, this line overwrites the .zshrc file.

AliOsm commented 1 month ago

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 commented 1 month ago

Hi 👋

Thanks for reporting!

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

prathameshzarkar9 commented 3 weeks ago

Hi @samruddhikhandale ,

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

prathameshzarkar9 commented 2 weeks ago

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

samruddhikhandale commented 1 week ago

Closing as fixed with https://github.com/devcontainers/features/pull/1069. Feel free to reopen if needed, thanks!

Mark-J-Lawrence commented 1 week ago

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 commented 1 week ago

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?