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

fatal error: concurrent map read and map write #3154

Closed
dhruvinsh opened this issue Aug 5, 2023 · 8 comments · Fixed by #3155 or #3160
Closed

fatal error: concurrent map read and map write #3154

dhruvinsh opened this issue Aug 5, 2023 · 8 comments · Fixed by #3155 or #3160
Labels
bug Something isn't working

Comments

@dhruvinsh
Copy link

dhruvinsh commented Aug 5, 2023

Describe the bug

If I have staged changes or unpunished changes in chezmoi repo (dotfiles), chezmoi apply -R almost always fail with errors message

With .chezmoiscript broken down to directory structure, chezmoi fail to read the data map.

map has no entry for key "chezmoi"

To reproduce

  • Make some changes in the repo
  • stage the change via git add .
  • try running chezmoi -R -- Result in error
  • commit the changes but do not push to remote
  • try running chezmoi -R -- Result in error

Expected behavior

It should not result in the error.

Output of command with the --verbose flag

chezmoi --verbose apply -R
fatal error: concurrent map read and map write

goroutine 8 [running]:
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).ExecuteTemplateData(0x140001c0780, {{0x1400057c050, 0x49}, {0x140002c2000, 0x33d, 0x33e}, {{0x0, 0x0}, {0x0, 0x0}, ...}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:769 +0x2f8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).executeTemplate(0x140001c0780, {{0x1400057c050?, 0x14000049c50?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1516 +0xd8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternal(0x140001c0780, {{0x1400057c050?, 0x0?}}, {{0x1400057c050?, 0x14000691e38?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1308 +0x120
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir.func1({0x14000123fc0?, 0x0?}, {{0x1400057c050?, 0x1?}}, {0x101e1e9e8, 0x1400057e000}, {0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1353 +0x3b4
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func1({0x101e1caa0, 0x14000135300})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:260 +0xe0
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func3()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:285 +0x2c
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa0

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x1400091e6b8?)
        runtime/sema.go:62 +0x2c
sync.(*WaitGroup).Wait(0x140001353c8)
        sync/waitgroup.go:116 +0x78
golang.org/x/sync/errgroup.(*Group).Wait(0x140001353c0)
        golang.org/x/[email protected]/errgroup/errgroup.go:53 +0x2c
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir({0x101e1c170, 0x14000120018}, {0x101e22df8, 0x1400071de40}, {{0x14000123fc0?, 0x1?}}, 0x14000201b00)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:292 +0x384
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir(0x140001c0780, {0x101e1c170, 0x14000120018}, {{0x14000123fc0?, 0x1400091e848?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1363 +0xb0
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Read.func2({{0x14000123fc0?, 0x35?}}, {0x101e1e9e8, 0x140002f0410}, {0x0?, 0x0?})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:946 +0x1150
github.com/twpayne/chezmoi/v2/internal/chezmoi.walkSourceDir({0x101e22df8, 0x1400071de40}, {{0x14000123fc0?, 0x1?}}, {0x101e1e9e8, 0x140002f0410}, 0x140007a7100)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:207 +0x60
github.com/twpayne/chezmoi/v2/internal/chezmoi.walkSourceDir({0x101e22df8, 0x1400071de40}, {{0x14000049c50?, 0x102795700?}}, {0x101e1e9e8, 0x140002f0000}, 0x140007a7100)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:234 +0x22c
github.com/twpayne/chezmoi/v2/internal/chezmoi.WalkSourceDir({0x101e22df8, 0x1400071de40}, {{0x14000049c50?, 0x1400011a030?}}, 0x1400091f100)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:186 +0x90
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Read(0x140001c0780, {0x101e1c170, 0x14000120018}, 0x1400052ef48)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1030 +0x190
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).newSourceState(0x14000012d80, {0x101e1c170, 0x14000120018}, 0x1400031b200, {0x0, 0x0, 0x1?})
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:1657 +0xaec
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).getSourceState(0x14000012d80, {0x101e1c170?, 0x14000120018?}, 0x101bc1620?)
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:1326 +0x5c
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).applyArgs(0x14000012d80, {0x101e1c170, 0x14000120018}, {0x101e22df8, 0x1400071dec0}, {{0x14000042005?, 0x0?}}, {0x1400014f700, 0x0, 0x2}, ...)
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:577 +0x360
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runApplyCmd(0x14000012d80, 0x0?, {0x1400014f700, 0x0, 0x2})
        github.com/twpayne/chezmoi/v2/internal/cmd/applycmd.go:48 +0xf4
github.com/spf13/cobra.(*Command).execute(0x1400031b200, {0x1400014f6c0, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x1400031a900)
        github.com/spf13/[email protected]/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:992
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0x1400091fde8?, {0x14000134010, 0x3, 0x3})
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:1172 +0x6c
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x101b0ab58, 0x6}, {0x101b0bd60, 0x28}, {0x101b0bb00, 0x14}, {0x101b0ba00, 0x8}}, {0x14000134010, 0x3, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:285 +0x194
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x101b0ab58, 0x6}, {0x101b0bd60, 0x28}, {0x101b0bb00, 0x14}, {0x101b0ba00, 0x8}}, {0x14000134010?, 0x14000052500?, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:108 +0x54
main.main()
        github.com/twpayne/chezmoi/v2/main.go:26 +0xd4

goroutine 6 [runnable]:
text/template/parse.(*Tree).operand(0x14000618a20)
        text/template/parse/parse.go:721 +0x5b8
text/template/parse.(*Tree).command(0x14000618a20)
        text/template/parse/parse.go:692 +0xc0
text/template/parse.(*Tree).pipeline(0x14000618a20, {0x10181a85e, 0x7}, 0x10)
        text/template/parse/parse.go:502 +0x66c
text/template/parse.(*Tree).action(0x14000618a20)
        text/template/parse/parse.go:418 +0x260
text/template/parse.(*Tree).textOrAction(0x14000618a20)
        text/template/parse/parse.go:374 +0x1e4
text/template/parse.(*Tree).itemList(0x14000618a20)
        text/template/parse/parse.go:353 +0xf4
text/template/parse.(*Tree).parseControl(0x14000618a20, 0x1, {0x10180993d, 0x2})
        text/template/parse/parse.go:531 +0xe0
text/template/parse.(*Tree).ifControl(0x14000618a20)
        text/template/parse/parse.go:570 +0x30
text/template/parse.(*Tree).action(0x14000618a20)
        text/template/parse/parse.go:407 +0x1bc
text/template/parse.(*Tree).textOrAction(0x14000618a20)
        text/template/parse/parse.go:374 +0x1e4
text/template/parse.(*Tree).parse(0x14000618a20)
        text/template/parse/parse.go:315 +0x204
text/template/parse.(*Tree).Parse(0x14000618a20, {0x140002b6300, 0x66f}, {0x0?, 0x140007180a0?}, {0x0?, 0x140004b37c8?}, 0x100c09844?, {0x140007180a0, 0x2, ...})
        text/template/parse/parse.go:251 +0x218
text/template/parse.Parse({0x14000620050, 0x43}, {0x140002b6300, 0x66f}, {0x0, 0x0}, {0x0, 0x0}, {0x140007180a0, 0x2, ...})
        text/template/parse/parse.go:66 +0xf0
text/template.(*Template).Parse(0x14000293880, {0x140002b6300, 0x66f})
        text/template/template.go:210 +0x870
github.com/twpayne/chezmoi/v2/internal/chezmoi.ParseTemplate({0x14000620050, 0x43}, {0x1400030ee00?, 0x102762fb0?, 0x101befe20?}, 0x1400011a0f0?, {{0x0, 0x0}, {0x0, 0x0}, ...})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/template.go:39 +0x2e4
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).ExecuteTemplateData(0x140001c0780, {{0x14000620050, 0x43}, {0x1400030ee00, 0x66f, 0x670}, {{0x0, 0x0}, {0x0, 0x0}, ...}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:755 +0x1b8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).executeTemplate(0x140001c0780, {{0x14000620050?, 0x14000049c50?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1516 +0xd8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternal(0x140001c0780, {{0x14000620050?, 0x0?}}, {{0x14000620050?, 0x1400049be38?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1308 +0x120
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir.func1({0x14000123fc0?, 0x0?}, {{0x14000620050?, 0x1?}}, {0x101e1e9e8, 0x14000622000}, {0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1353 +0x3b4
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func1({0x101e1caa0, 0x14000135340})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:260 +0xe0
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func3()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:285 +0x2c
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa0

goroutine 7 [runnable]:
text/template.goodName({0x1018538f4, 0xf})
        text/template/funcs.go:124 +0x1e4
text/template.addValueFuncs(0x14000731858?, 0x100a6246c?)
        text/template/funcs.go:89 +0x88
text/template.(*Template).Funcs(0x1400051aa80, 0x1400011a830?)
        text/template/template.go:181 +0x150
github.com/twpayne/chezmoi/v2/internal/chezmoi.ParseTemplate({0x140005be050, 0x46}, {0x140005c2000?, 0x102762fb0?, 0x101befe20?}, 0x1400011a0f0?, {{0x0, 0x0}, {0x0, 0x0}, ...})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/template.go:38 +0x2c0
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).ExecuteTemplateData(0x140001c0780, {{0x140005be050, 0x46}, {0x140005c2000, 0x23d, 0x23e}, {{0x0, 0x0}, {0x0, 0x0}, ...}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:755 +0x1b8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).executeTemplate(0x140001c0780, {{0x140005be050?, 0x14000049c50?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1516 +0xd8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternal(0x140001c0780, {{0x140005be050?, 0x0?}}, {{0x140005be050?, 0x14000080e38?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1308 +0x120
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir.func1({0x14000123fc0?, 0x0?}, {{0x140005be050?, 0x1?}}, {0x101e1e9e8, 0x140005c0000}, {0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1353 +0x3b4
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func1({0x101e1caa0, 0x14000135200})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:260 +0xe0
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func3()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:285 +0x2c
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa0

goroutine 9 [runnable]:
github.com/mitchellh/reflectwalk.walk({0x101c29620?, 0x140006de340?, 0x140006e00a0?}, {0x101dc3d60, 0x140006e00a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:198 +0x5b0
github.com/mitchellh/reflectwalk.walkMap({0x101c535e0?, 0x14000644210?, 0x140006e00a0?}, {0x101dc3d60, 0x140006e00a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:252 +0x208
github.com/mitchellh/reflectwalk.walk({0x101c535e0?, 0x14000644210?, 0x140006e00a0?}, {0x101dc3d60, 0x140006e00a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:200 +0x4e8
github.com/mitchellh/reflectwalk.Walk({0x101c535e0?, 0x14000644210?}, {0x101dc3d60, 0x140006e00a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:99 +0x158
github.com/mitchellh/copystructure.Config.Copy({0xa0?, 0x0?, 0x0?}, {0x101c535e0?, 0x14000644210})
        github.com/mitchellh/[email protected]/copystructure.go:116 +0x1d0
github.com/mitchellh/copystructure.Copy(...)
        github.com/mitchellh/[email protected]/copystructure.go:36
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*Template).Execute(0x140006e4120, {0x101c535e0?, 0x14000644210?})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/template.go:62 +0x44
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).ExecuteTemplateData(0x140001c0780, {{0x140004a0050, 0x48}, {0x140004aa000, 0x19d, 0x200}, {{0x0, 0x0}, {0x0, 0x0}, ...}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:774 +0x3b8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).executeTemplate(0x140001c0780, {{0x140004a0050?, 0x14000049c50?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1516 +0xd8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternal(0x140001c0780, {{0x140004a0050?, 0x0?}}, {{0x140004a0050?, 0x1400049fe38?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1308 +0x120
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir.func1({0x14000123fc0?, 0x0?}, {{0x140004a0050?, 0x1?}}, {0x101e1e9e8, 0x140004a2000}, {0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1353 +0x3b4
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func1({0x101e1caa0, 0x14000135280})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:260 +0xe0
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func3()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:285 +0x2c
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa0

goroutine 10 [runnable]:
runtime.Gosched(...)
        runtime/proc.go:321
reflect.Value.MapKeys({0x101c535e0?, 0x14000644210?, 0x14000644210?})
        reflect/value.go:1776 +0xd4
github.com/mitchellh/reflectwalk.walkMap({0x101c535e0?, 0x14000644210?, 0x140006460a0?}, {0x101dc3d60, 0x140006460a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:228 +0xac
github.com/mitchellh/reflectwalk.walk({0x101c535e0?, 0x14000644210?, 0x140006460a0?}, {0x101dc3d60, 0x140006460a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:200 +0x4e8
github.com/mitchellh/reflectwalk.Walk({0x101c535e0?, 0x14000644210?}, {0x101dc3d60, 0x140006460a0})
        github.com/mitchellh/[email protected]/reflectwalk.go:99 +0x158
github.com/mitchellh/copystructure.Config.Copy({0x80?, 0x0?, 0x0?}, {0x101c535e0?, 0x14000644210})
        github.com/mitchellh/[email protected]/copystructure.go:116 +0x1d0
github.com/mitchellh/copystructure.Copy(...)
        github.com/mitchellh/[email protected]/copystructure.go:36
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*Template).Execute(0x1400064a060, {0x101c535e0?, 0x14000644210?})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/template.go:62 +0x44
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).ExecuteTemplateData(0x140001c0780, {{0x1400017edc0, 0x44}, {0x140003db400, 0xeb, 0x200}, {{0x0, 0x0}, {0x0, 0x0}, ...}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:774 +0x3b8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).executeTemplate(0x140001c0780, {{0x1400017edc0?, 0x14000049c01?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1516 +0xd8
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternal(0x140001c0780, {{0x1400017edc0?, 0x0?}}, {{0x1400017edc0?, 0x1400006e638?}})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1308 +0x120
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).addExternalDir.func1({0x14000123fc0?, 0x0?}, {{0x1400017edc0?, 0x1?}}, {0x101e1e9e8, 0x140002f04e0}, {0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1353 +0x3b4
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func1({0x101e1caa0, 0x14000135240})
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:260 +0xe0
github.com/twpayne/chezmoi/v2/internal/chezmoi.concurrentWalkSourceDir.func3()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/system.go:285 +0x2c
golang.org/x/sync/errgroup.(*Group).Go.func1()
        golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
        golang.org/x/[email protected]/errgroup/errgroup.go:72 +0xa0

Output of chezmoi doctor

RESULT    CHECK                MESSAGE
ok        version              v2.36.1, commit 0b0fa89f612f5f885ccfc8c3890f515cc668c5c6, built at 2023-07-30T11:56:41Z, built by Homebrew
ok        latest-version       v2.36.1
ok        os-arch              darwin/arm64
ok        uname                Darwin artemis.lan 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112 arm64
ok        go-version           go1.20.6 (gc)
ok        executable           /opt/homebrew/bin/chezmoi
ok        upgrade-method       brew-upgrade
ok        config-file          ~/.config/chezmoi/chezmoi.toml, last modified 2023-07-14T23:52:39-04:00
warning   source-dir           ~/.local/share/chezmoi is a git working tree (dirty)
ok        suspicious-entries   no suspicious entries
warning   working-tree         ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir             ~ is a directory
ok        umask                022
ok        cd-command           found /bin/zsh
ok        cd-args              /bin/zsh
info      diff-command         not set
ok        edit-command         found /opt/homebrew/bin/nvim
ok        edit-args            /opt/homebrew/bin/nvim
ok        git-command          found /usr/bin/git, version 2.39.2
ok        merge-command        found /usr/bin/vimdiff
ok        shell-command        found /bin/zsh
ok        shell-args           /bin/zsh
ok        age-command          found /opt/homebrew/bin/age, version 1.1.1
info      gpg-command          gpg not found in $PATH
info      pinentry-command     not set
info      1password-command    op not found in $PATH
info      bitwarden-command    bw not found in $PATH
info      dashlane-command     dcli not found in $PATH
info      gopass-command       gopass not found in $PATH
info      keepassxc-command    keepassxc-cli not found in $PATH
info      keepassxc-db         not set
info      keeper-command       keeper not found in $PATH
info      lastpass-command     lpass not found in $PATH
info      pass-command         pass not found in $PATH
info      passhole-command     ph not found in $PATH
info      rbw-command          rbw not found in $PATH
info      vault-command        vault not found in $PATH
info      vlt-command          vlt not found in $PATH
info      secret-command       not set```

</details>
@halostatue
Copy link
Collaborator

Can you try this again with 2.35.2 and 2.36.0? There are two changes that seem like they could have introduced a change: #3108 (2.36.0) and #3129 (2.36.1). If it happens with 2.35.2, then we need to dig a bit deeper to figure out the breakage.

@halostatue halostatue added bug Something isn't working waiting for response Waiting for a response labels Aug 6, 2023
@twpayne twpayne removed the waiting for response Waiting for a response label Aug 6, 2023
@twpayne
Copy link
Owner

twpayne commented Aug 6, 2023

This is definitely a bug in chezmoi caused by #3108.

chezmoi evaluates the source state concurrently for speed, and I forgot this when implementing #3108. The externals are stored in a map, and so having multiple external files leads to the concurrent map access panic seen here.

Working on a fix now.

Edit: different issue, oops.

@twpayne
Copy link
Owner

twpayne commented Aug 6, 2023

This is because of a hack I did avoid a deep copy of the template data when setting template-specific values (currently only .chezmoi.sourceFile). #3155 should fix it.

@dhruvinsh
Copy link
Author

I have tired the latest version, but still 1 in 3 tries it fails for me.

chezmoi: /Users/ds/.local/share/chezmoi/home/.chezmoiexternals/oh-my-zsh.yaml.tmpl: template: /Users/ds/.local/share/chezmoi/home/.chezmoiexternals/oh-my-zsh.yaml.tmpl:3:19: executing "/Users/ds/.local/share/chezmoi/home/.chezmoiexternals/oh-my-zsh.yaml.tmpl" at <.chezmoi.os>: map has no entry for key "chezmoi"

@twpayne
Copy link
Owner

twpayne commented Aug 7, 2023

I'm unable to duplicate this error with your dotfiles in a fresh Ubuntu Docker image. I cloned at commit a3c673bf9666a10c12de72ac6e06dec3eb1df315, lightly edited .chezmoi.toml.tmpl to remove the dependency on hostnamectl, and ran chezmoi diff -x encrypted.

Do you have a small cases that reproduces the problem?

@twpayne
Copy link
Owner

twpayne commented Aug 7, 2023

Note also that this is a different error to the original one reported in this issue.

@twpayne
Copy link
Owner

twpayne commented Aug 7, 2023

Wait, I can reproduce it myself now.

@dhruvinsh
Copy link
Author

dhruvinsh commented Aug 7, 2023

Note also that this is a different error to the original one reported in this issue.

For me the errors are interchangeable. Sometime I get single line error (as posted recently), sometime I get full trace of error log as mentioned in the main thread.

Wait, I can reproduce it myself now.

yeah, it takes some tries to produce the error. I will give #3160 a try, if that fix it.

UPDATE:
@twpayne I tried the binary from #3160 and it seems it fixed the issue for me. I tried multiple times and no error. As soon as I switched to release version, error pop right after 2 tries.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
3 participants