Carol.Kar
Carol.Kar

Reputation: 5345

Unable to index file

I have cloned my repo from github with my running git git version 2.16.2.windows.1.

However, when I want to commit it I get the following error:

error: open("src/hoc/Aux.js"): No such file or directory
error: unable to index file src/hoc/Aux.js
fatal: adding files failed

Below you can find the folder and file content:

enter image description here

Any suggestion what I am doing wrong?

I appreciate your replies!

Update

Please find below what git status gives me:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore
        README.md
        config/
        package-lock.json
        package.json
        public/
        scripts/
        src/

nothing added to commit but untracked files present (use "git add" to track)

UPDATE 1

I still get the same error, even when manually adding the src folder:

marcus@Marcus-PC MINGW64 ~/Desktop/Coding Projects/demo-react-burger-builder (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore
        README.md
        config/
        package-lock.json
        package.json
        public/
        scripts/
        src/

nothing added to commit but untracked files present (use "git add" to track)

Upvotes: 14

Views: 13508

Answers (2)

axiac
axiac

Reputation: 72206

A comment of the OP on this answer reveals the cause:

I now removed the aux.js and now everything works fine.

AUX is a special file name in Windows (inherited from the old ages of MS-DOS). It is a special file that denotes a device. While on other OSes (Unix-based) the special device files are located in the /dev directory, MS-DOS (and its successor Windows) recognizes the name in any directory and treats it as a special file. This certainly happens in the Command Prompt (for compatibility with the old MS-DOS programs) but it seems it happens in other contexts too.

The name being special and recognized in any directory, the OS code that handles the file names ignores the provided aux.js file (and its path) and handles aux as the special device file AUX. The character case is not important, on Windows file systems aux and Aux are the same as AUX. Because it thinks it has found a special name, it ignores the file extension.

The same thing happens for NUL, CON, PRN and other special names. Check the complete list here: https://en.wikipedia.org/wiki/Device_file#MS-DOS

There is no solution for this, only workarounds. If you are stuck on Windows or the project is developed on Windows by coworkers, the only way to circumvent this is to avoid these special names. Aux is probably the short of Auxiliary.
Use longer names.


An interesting reading (and the source of wisdom that provided the information I put into this answer) is the article "What's the deal with those reserved filenames like NUL and CON?" written by Microsoft senior developer Raymond Chen on his blog "The Old New Thing" in 2003.

Upvotes: 27

Karthik Mydur
Karthik Mydur

Reputation: 21

Even I was facing the same issue that because Aux is a special name in windows. You can rename Aux file "Auxiliary" which will work un doubtedly.

Upvotes: 2

Related Questions