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

File Name Too Long Error On Windows PowerShell 7 #853

Open
alexAtSourcegraph opened this issue Oct 3, 2022 · 1 comment
Open

File Name Too Long Error On Windows PowerShell 7 #853

alexAtSourcegraph opened this issue Oct 3, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@alexAtSourcegraph
Copy link

fatal: unable to stat ‘path/to/files’ Filename too long: exit status 128 error when repos have long names.

Effort tried to rectify issue:

  • setting git config –system core.longpaths to true
  • enabling long paths in Windows
@alexAtSourcegraph alexAtSourcegraph added the bug Something isn't working label Oct 3, 2022
@manios
Copy link

manios commented Dec 14, 2022

Hi @alexAtSourcegraph !

I had the same issue as you using Git for Windows and Git bash in Windows 10:

manios@LAPTOP-WIN10 MINGW64 /c/goprojects/src-cli/cmd/src (main)
$ ./src.exe batch preview -f ../../deleteean.yml
✅ Parsing batch spec
✅ Resolving namespace
✅ Preparing container images  ███████████████████  100%✅ Set workspace type
✅ Resolved 1 workspaces from 1 repositories
✅ Found 0 cached changeset specs; 1 task needs to be executed
✅ Executing... (1/1, 1 errored)  ███████ 100%│
└── gitlab.internal.manios.local/maniosorg/myprojects/jetfirestarter  creating workspace: preparing local git repo: git add failed: 'git add --force --all' failed: warning: could not open directory 'src/test/java/org/manios/jfs/service/impl...  0s
❌ Error:
   gitlab.internal.manios.local/maniosorg/myprojects/jetfirestarter:
   creating workspace: preparing local git repo: git add failed: 'git add --force --all' failed: warning: could not open directory 'src/test/java/org/manios/jfs/service/impl': Filename too long
   fatal: unable to stat 'src/main/java/org/manios/jfs/service/impl/FirestarterImpl.java': Filename too long: exit status 128
   Log: C:\Users\manios\AppData\Local\Temp\changeset-gitlab.internal.manios.local.maniosorg.jetfirestarter-01c9cda30fb8dcd2701303efc5d2e6e65218d952.2041328270.log

The problem is that src-cli is configured to ignore your internal Git configuration. Therefore setting git config -system core.longpaths to true will be ignored.

The only way to make it work is to patch locally the internal\batches\workspace\git.go as :

diff --git a/internal/batches/workspace/git.go b/internal/batches/workspace/git.go
index 20c20d1..ef409b2 100644
--- a/internal/batches/workspace/git.go
+++ b/internal/batches/workspace/git.go
@@ -12,9 +12,9 @@ func runGitCmd(ctx context.Context, dir string, args ...string) ([]byte, error)
        cmd := exec.CommandContext(ctx, "git", args...)
        cmd.Env = []string{
                // Don't use the system wide git config.
-               "GIT_CONFIG_NOSYSTEM=1",
+               // "GIT_CONFIG_NOSYSTEM=1",
                // And also not any other, because they can mess up output, change defaults, .. which can do unexpected things.
-               "GIT_CONFIG=/dev/null",
+               // "GIT_CONFIG=/dev/null",
                // Don't ask interactively for credentials.
                "GIT_TERMINAL_PROMPT=0",
                // Set user.name and user.email in the local repository. The user name and

Then, if you compile it locally and run it, it works. I could not find any other straightforward solution at the moment.

Best regards,
Christos

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

No branches or pull requests

2 participants