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

chezmoi add mishandles cases where entry or parent is external #1574

Open
twpayne opened this issue Oct 31, 2021 · 4 comments
Open

chezmoi add mishandles cases where entry or parent is external #1574

twpayne opened this issue Oct 31, 2021 · 4 comments
Labels
bug Something isn't working v3 Planned for v3

Comments

@twpayne
Copy link
Owner

twpayne commented Oct 31, 2021

Describe the bug

As reported by @dhruvinsh in #1205, chezmoi add fails if the path is in a directory implicitly created by an external.

To reproduce

similar to this another issue found, file: .chezmoiexternal.toml

[".oh-my-zsh"]
    type = "archive"
    url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"
    exact = true
    stripComponents = 1
[".oh-my-zsh/custom/plugins/zsh-syntax-highlighting"]
    type = "archive"
    url = "https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz"
    exact = true
    stripComponents = 1

Everything is working as expect with chezmoi apply. But now while my config is managed by chezmoi I decided to add aliases in .oh-my-zsh/custom/aliases.zsh. and I wanted to track it by chezmoi but when i try to add it by chezmoi I receive below error

> ~ chezmoi add .oh-my-zsh/custom/aliases.zsh
chezmoi: stat /home/ds/.local/share/chezmoi/https:/github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz: no such file or directory

Expected behavior

chezmoi add adds the file.

@dhruvinsh
Copy link

@twpayne I would like to point out something here:
Issue #2006 and issue #1574 (this issue) have somewhat similarity but still I believe they are different.

In issue #2006 I had .config/nvim being managed by .chezmoiexternal and I was trying to add .config/direnv (a separate) directory. Thus I was getting error:

chezmoi: mkdir /home/ds/.local/share/chezmoi/dot_config/direnv: no such file or directory

But here in this case, .chezmoiexternal is managing .oh-my-zsh and .oh-my-zsh/custom/plugins/zsh-syntax-highlighting. And when trying to add .oh-my-zsh/custom/aliases.zsh (same root as one of the .chezmoiexternal) chezmoi give below erro:

chezmoi: stat /home/ds/.local/share/chezmoi/https:/github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz: no such file or directory

I tried few test and it seems that workaround only works if mkdir error persists. But in case of state error then workaround does not work and which made me believe that #2006 and this issue are different.

@twpayne twpayne added the patience Patience required, there is no date for this being fixed label May 18, 2022
@twpayne
Copy link
Owner Author

twpayne commented May 23, 2022

When this issue is fixed, we should also update the docs to include Felipe's neat trick in this comment.

@twpayne twpayne added v3 Planned for v3 and removed patience Patience required, there is no date for this being fixed labels Jan 2, 2023
awood added a commit to awood/dotfiles that referenced this issue Jul 17, 2023
See twpayne/chezmoi#2006 and
twpayne/chezmoi#1574.  Basically, a workaround
is required if using chezmoi on a directory otherwise managed by
a chezmoi external.
@twpayne
Copy link
Owner Author

twpayne commented Feb 18, 2024

This also applies to files. See #3559 (comment).

@twpayne twpayne changed the title chezmoi add fails when directory is implicit via external chezmoi add mishandles cases where entry or parent is external Feb 19, 2024
@koiralakiran1
Copy link
Contributor

koiralakiran1 commented Apr 23, 2024

Adding the workaround reference here, as this issue seems more prominent. Mentioned in #2006 (comment)

Temporary work around applied:

Manually create a dot_config directory and within that directory touch .keep to force chezmoi to track it.

now using chezmoi add ~/.config/direnv/direnvrc works as expected.

In addition to this you'll need to make your externals exact = false in the externals toml that conflict. Eg: .chezmoiexternal.toml

[".oh-my-zsh"]
    type = "archive"
    url = "https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz"
    exact = false
    stripComponents = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3 Planned for v3
Projects
None yet
Development

No branches or pull requests

3 participants