Comments (7)
Actually, I think #3627 catches all of them.
from chezmoi.
@twpayne Not quite sure where to fix this, because this look like it's breaking out in vfs.Walk
and is unable to reenter because of the use of dirEntry.Info()
in walk/5
. Because that return
is breaking out of for … range dirEntries
, there's no way to continue without this.
This may be where WalkDir
and/or WalkDirSlash
are required, because at least for unmanaged, the dirEntry.Info()
appears to be mostly unnecessary, but it would require a different approach.
- Would you like a parallel ticket opened for twpayne/go-vfs
- Should we implement
WalkDir
and shiftchezmoi unmanaged
to using WalkDir or should we look at some other way to do this?
A simplistic fix would be:
diff --git c/walk.go i/walk.go
index 1075f1225194..d6c090e1ac66 100644
--- c/walk.go
+++ i/walk.go
@@ -6,10 +6,11 @@
import (
"errors"
"io/fs"
"path/filepath"
"sort"
+ "syscall"
)
// SkipDir is fs.SkipDir.
var SkipDir = fs.SkipDir
@@ -42,15 +43,20 @@ func walk(fileSystem LstatReadDirer, path string, walkFn filepath.WalkFunc, info
return err
}
sort.Sort(dirEntriesByName(dirEntries))
for _, dirEntry := range dirEntries {
name := dirEntry.Name()
+
if name == "." || name == ".." {
continue
}
info, err := dirEntry.Info()
if err != nil {
+ if errors.Is(err, syscall.EPERM) {
+ continue
+ }
+
return err
}
if err := walk(fileSystem, filepath.Join(path, dirEntry.Name()), walkFn, info, nil); err != nil {
return err
}
from chezmoi.
Thank you for this.
I think there are bugs in both twpayne/go-vfs and in chezmoi:
- The bug in twpayne/go-vfs is that
walk/5
should callwalkFn
when it encounters any error so that the caller can decide how to handle the error. In this case,walk/5
should callwalkFn
but doesnt. - Within chezmoi, the
-k
/--keep-going
flag should instruct chezmoi to keep going in this case.
No need for a separate issue in twpayne/go-vfs, but I will request your review on the PR :)
from chezmoi.
Unfortunately, this is not resolved.
$ chezmoi unmanaged --keep-going
chezmoi: /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: lstat /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: operation not permittedpanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x101265458]
goroutine 1 [running]:
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runUnmanagedCmd.func1({0x140005b8e60, 0x50}, {0x0, 0x0}, {0x0?, 0x0?})
/home/runner/work/chezmoi/chezmoi/internal/cmd/unmanagedcmd.go:76 +0x348
github.com/twpayne/chezmoi/v2/internal/chezmoi.Walk.func1({0x140005b8e60?, 0x140005787b0?}, {0x0?, 0x0?}, {0x0?, 0x0?})
/home/runner/work/chezmoi/chezmoi/internal/chezmoi/system.go:157 +0x38
github.com/twpayne/go-vfs/v5.walk({0x1293e54e0, 0x10244caa0}, {0x140005b8e60, 0x50}, 0x14000809688, {0x0, 0x0}, {0x0?, 0x0?})
/home/runner/go/pkg/mod/github.com/twpayne/go-vfs/[email protected]/walk.go:33 +0x80
github.com/twpayne/go-vfs/v5.walk({0x1293e54e0, 0x10244caa0}, {0x14000477ce0, 0x29}, 0x14000809688, {0x101928040, 0x1400053ec30}, {0x0?, 0x0?})
/home/runner/go/pkg/mod/github.com/twpayne/go-vfs/[email protected]/walk.go:65 +0x338
github.com/twpayne/go-vfs/v5.walk({0x1293e54e0, 0x10244caa0}, {0x14000907188, 0x15}, 0x14000809688, {0x101928040, 0x1400053e5b0}, {0x0?, 0x0?})
/home/runner/go/pkg/mod/github.com/twpayne/go-vfs/[email protected]/walk.go:65 +0x338
github.com/twpayne/go-vfs/v5.walk({0x1293e54e0, 0x10244caa0}, {0x1400004a035, 0xd}, 0x14000809688, {0x101928040, 0x14000713ad0}, {0x0?, 0x0?})
/home/runner/go/pkg/mod/github.com/twpayne/go-vfs/[email protected]/walk.go:65 +0x338
github.com/twpayne/go-vfs/v5.Walk({0x1293e54e0, 0x10244caa0}, {0x1400004a035, 0xd}, 0x14000809688)
/home/runner/go/pkg/mod/github.com/twpayne/go-vfs/[email protected]/walk.go:76 +0x68
github.com/twpayne/chezmoi/v2/internal/chezmoi.Walk({0x10192dcb0?, 0x1400041af40?}, {0x1400004a035, 0xd}, 0x1018ab140?)
/home/runner/work/chezmoi/chezmoi/internal/chezmoi/system.go:159 +0x78
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runUnmanagedCmd(0x140001ad008, 0x14000342908?, {0x140003150b0?, 0x0?, 0x0?}, 0x140001a2c00)
/home/runner/work/chezmoi/chezmoi/internal/cmd/unmanagedcmd.go:93 +0x324
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).newUnmanagedCmd.(*Config).makeRunEWithSourceState.func1(0x14000342908, {0x140003150b0, 0x0, 0x1})
/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:1532 +0x88
github.com/spf13/cobra.(*Command).execute(0x14000342908, {0x14000315090, 0x1, 0x1})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x14000164308)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0x1400079fde8?, {0x1400003a340, 0x2, 0x2})
/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:1201 +0x70
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x1015d3648, 0x6}, {0x1015d48e0, 0x28}, {0x1015d45d0, 0x14}, {0x1015d44f0, 0xa}}, {0x1400003a340, 0x2, ...})
/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:279 +0x17c
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x1015d3648, 0x6}, {0x1015d48e0, 0x28}, {0x1015d45d0, 0x14}, {0x1015d44f0, 0xa}}, {0x1400003a340, 0x2, ...})
/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:105 +0x5c
main.main()
/home/runner/work/chezmoi/chezmoi/main.go:24 +0xd8
Beyond the crash, having to always remember chezmoi unmanaged -k
on macOS 14.3 or higher is suboptimal, because that directory is not going away (and I don't consider adding the file to .chezmoiignore
to be a proper solution, either).
Printing a warning about files/directories where EPERM (errno 1, "Operation not permitted") happens is fine, but for that case, chezmoi / go-vfs should probably be turning that into a continue
operation.
from chezmoi.
The crash happens at internal/cmd/unmanagedcmd.go:76
because the passed fileInfo
is null
. This case needs to be handled, but it is insufficient.
chezmoi/internal/cmd/unmanagedcmd.go
Lines 76 to 89 in 5bb87f1
After returning from the passed walkFunc
, go-vfs/walk.go:58
will crash because it tries to access the very same info
null pointer.
switch err := walkFn(path, info, err); {
case errors.Is(err, fs.SkipDir) && info.IsDir():
// Do nothing.
case err != nil:
return err
}
The latter can be made to work because it still has access to dirEntry
(from go-vfs/walk.go:50
) that has dirEntry.IsDir()
for checking this.
I suspect that for chezmoi unmanaged
, this would be a good opportunity use the (as yet unimplemented) WalkDir
function since it never asks for fs.FileInfo
, but it will still report an error (Errno.EPERM
) on the specific file mentioned.
from chezmoi.
Nice. There is one small thing:
chezmoi: /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: lstat /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: operation not permitted.CFUserTextEncoding
I think that this is more general where some error outputs don't have newlines; I can open a new issue for this.
The output should be:
chezmoi: /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: lstat /Users/halostatue/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv: operation not permitted.
CFUserTextEncoding
from chezmoi.
I can open a new issue for this.
Please do open a new issue for this. chezmoi already attempts to tidy up error messages, but clearly it can do better here.
from chezmoi.
Related Issues (20)
- Add support for template prefix HOT 3
- Support `failure` hooks and scripts HOT 7
- `--follow` and `--recursive` add seem to conflict
- Extend re-add command to add new files
- .chezmoiignore thinks closing braces are a pattern HOT 3
- Trouble ignoring certain files
- `chezmoi edit-config-template` creates initial template with world-writable permissions HOT 2
- Using environment variable in onepasswordRead HOT 2
- Support chmod in attributes HOT 5
- Powershell one-line install on Windows 11 error - update script at https://get.chezmoi.io/ps1 HOT 1
- run time bug when `chezmoi doctor` invoked HOT 6
- Make accidental removal harder
- forced update says "Already up to date." HOT 1
- Ability to dry-run / diff scripts HOT 5
- Local repository. HOT 7
- Documentation update "Why do I get a blank buffer or empty file when running chezmoi edit" HOT 1
- Import/merge separate source directories? HOT 2
- Set command line options via environment variables HOT 1
- Precedence of .chezmoiremove vs. exact_ attributes?
- SOPS Support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chezmoi.