No such file or directory - git ls-files -- WINDOWS
- Right-click "My computer" and choose Properties
- Click Advanced system settings
- Click on Environment Variables, under System Variables, find
PATH
, and add the directory wheregit.exe
is located. Directories are separated with semicolons.
The funny thing is, that this simple operation is very uncomfortable, especially when your PATH
is long and people created tools, only to edit system path.
fatal: Unable to read current working directory: No such file or directory
Your current directory doesn't exist on the master branch. It was deleted when you checked it out. cd ..
a few times until you find a directory that exists.
How to solve '.git/index.lock': No such file or directory' error?
On Windows, this may happen if you enabled the "Ransomware protection" in Setting > Windows security > Virus & threat protection.
You need to add an exclusion for git.exe, or move the project outside a protected folder.
Git no such file or directory
Pathname too long problem
Given that the OP has already tried removing and re-adding the file without success, it is possible that the crux of the problem is that the complete path of Con.php
has hit the 260 character limit in windows. However, when I tried to reproduce this problem, the error message clearly said fatal: unable to stat 'very/long/path/name': Filename too long
so am not certain that that is the problem.
To check if this is the problem, switch to the directory containing Con.php
and execute the following:
pwd -W | wc -c
That should give you a count of the number of characters in the windows path of the current directory. If the count is not >=260 then this is not the problem and I would recommend moving on to Debugging other issues
section below. However, if the count is >= 260, then proceed as follows:
git config --system core.longpaths true
and then try adding the file again.
See this in action below, which creates a path with >260 characters and the sets the above option to prove that it fixes the problem.
$ git add 12345
fatal: unable to stat 'This/Is/A/Very/long/pathname/with/more/than/two/hundred/and/sixty/characters/This/Is/A/Very/long/pathname/with/more/than/two/hundred/and/sixty/characters/This/Is/A/Very/long/pathname/with/more/than/two/hundred/more/dir/12345': Filename too long
$ git config --system core.longpaths true
$ git add 12345 #Notice that there is no error now
$ git status #Shows that the file was successfully staged
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 12345
Why is this configuration not the default?
If you were wondering about that, read this:
Windows does not properly support files and directories longer than
260 characters. This applies to Windows Explorer, cmd.exe and many
other applications (including many IDEs as well as bash, perl and tcl
that come with Git for Windows).
and note this caveat:
Scripted git commands may still fail with this option, so use at your
own risk
Debugging other issues
If too-long-a-pathname is not the problem, then try executing the following command (of course changing git add 12345
to git add app/CodeBehind/Con.php
) and look at the ouptput for clues (and add this to your question to assist other readers in finding out the issue) :
$ set -x; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 git add 12345; set +x;
+ GIT_TRACE=2
+ GIT_CURL_VERBOSE=2
+ GIT_TRACE_PERFORMANCE=2
+ GIT_TRACE_PACK_ACCESS=2
+ GIT_TRACE_PACKET=2
+ GIT_TRACE_PACKFILE=2
+ GIT_TRACE_SETUP=2
+ GIT_TRACE_SHALLOW=2
+ git add 12345
16:06:04.269773 trace.c:333 setup: git_dir: .git
16:06:04.269773 trace.c:334 setup: git_common_dir: .git
16:06:04.269773 trace.c:335 setup: worktree: C:/Users/az/test-long-path-problems
16:06:04.269773 trace.c:336 setup: cwd: C:/Users/az/test-long-path-problems
16:06:04.269773 trace.c:337 setup: prefix: This/Is/A/Very/long/pathname/with/more/than/two/hundred/and/sixty/characters/This/Is/A/Very/long/pathname/with/more/than/two/hundred/and/sixty/characters/This/Is/A/Very/long/pathname/with/more/than/two/hundred/more/dir/
16:06:04.269773 git.c:350 trace: built-in: git 'add' '12345'
16:06:04.269773 trace.c:435 performance: 0.006209300 s: git command: 'git.exe' 'add' '12345'
+ set +x
Github Actions: No such file or Directory error
Answer
After smashing my head against a wall for several days, I think I finally figured it out.
The command was failing because of how cmd mkdir
behaves, in that, it behaves different from the one in poewrshell.
By changing the Makefile
to only create folders if they don't exist already, I was able to fix the issue while still mantaining backwards compatibility, which was one of my requirements.
I have submitted a PR with this fix and at the time of this writing, I am happy to announce it was already merged into master:
- https://github.com/bake-bake-bake/bakeware/pull/128
Related Topics
Why Is Rake Not Able to Invoke Multiple Tasks Consecutively
Elasticsearch & Tire: Using Mapping and To_Indexed_JSON
Generate an HTML Table from an Array of Hashes in Ruby
Redirect User After Log in Only If It's on Root_Path
How to Get the Last SQL Query Performed by Activerecord in Ruby on Rails
Reading and Updating Yaml File by Ruby Code
Is Ruby Really an Interpreted Language If All of Its Implementations Are Compiled into Bytecode
How to Copy File Across Buckets Using Aws-S3 or Aws-Sdk Gem in Ruby on Rails
Check If a Constant Is Already Defined
Difference Between Resource and Resources in Rails Routing
Before/After Suite When Using Ruby Minitest
Rack::Request - How to Get All Headers
Rails Put Validation in a Module Mixin
Nested Forms in Rails - Accessing Attribute in Has_Many Relation