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

"warning: unable to access '': Invalid argument" after staging a file #1301

Closed
pkonecki opened this issue Sep 15, 2017 · 7 comments
Closed
Labels

Comments

@pkonecki
Copy link

  • [ x] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.14.1.windows.1
built from commit: 82d9b3f3b2407b52251620597d4b14933685459d
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [version 10.0.15063]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Path Option: BashOnly
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Nothing I can think of.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git bash (MinGW64)

Clone some repository (was able to repro on any freshly cloned repo)
$ git clone <some repo>
Modifiy some file
$ echo "test" >> README.md
Add it
$ git add README.md
warning: unable to access '': Invalid argument
File is added, no problem, but this warning is always shown after adding a file
$ git status
warning: unable to access '': Invalid argument
On branch master
Your branch is up-to-date with 'origin/master'.
$ git reset README.md
warning: unable to access '': Invalid argument
Unstaged changes after reset:
M       README.md
Changes to be committed:
        modified:   README.md

  • What did you expect to occur after running these commands?

No warning

  • What actually happened instead?

Warning:
warning: unable to access '': Invalid argument

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

No specific repository

@dscho dscho added the unclear label Sep 18, 2017
@dscho
Copy link
Member

dscho commented Sep 18, 2017

I have never seen anything like this. The warning stems from the warn_on_inaccessible() function called when access() or fopen() fail to access files or directories due to permission problems. Out of the callers, the ones stick out that read the excludes, the attributes and the grafts.

Is it possible that you have any GIT_* environment variables with empty values? Or config settings with empty values?

@pkonecki
Copy link
Author

Neither.

I tried this to get some more info:

$ 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 status -v -v; 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 status -v -v
16:10:46.891274 trace.c:333             setup: git_dir: .git
16:10:46.891775 trace.c:334             setup: git_common_dir: .git
16:10:46.891775 trace.c:335             setup: worktree: C:/Users/eugen/Launchpy
16:10:46.891775 trace.c:336             setup: cwd: C:/Users/eugen/Launchpy
16:10:46.891775 trace.c:337             setup: prefix: (null)
16:10:46.892275 git.c:328               trace: built-in: git 'status' '-v' '-v'
16:10:46.895281 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 1930
16:10:46.895782 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 13114
warning: unable to access '': Invalid argument
16:10:46.896282 sha1_file.c:2493        .git/objects/pack/pack-f4966b37f30d875770296518385d4298c39e04b6.pack 11571
16:10:46.896282 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 19840
warning: unable to access '': Invalid argument
16:10:46.896783 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 37022
16:10:46.898786 sha1_file.c:2493        .git/objects/pack/pack-f4966b37f30d875770296518385d4298c39e04b6.pack 11571
warning: unable to access '': Invalid argument
16:10:46.899286 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 19840
16:10:46.899787 sha1_file.c:2493        .git/objects/pack/pack-49038ce364a86426c885603c9aad46f5490542cb.pack 37022
16:10:46.900288 trace.c:435             performance: 0.010121271 s: git command: 'C:\Program Files\Git\mingw64\bin\git.exe' 'status' '-v' '-v'
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
        modified:   .gitattributes
        modified:   aliases
        modified:   bashrc

Changes to be committed:
diff --git c/.gitattributes i/.gitattributes
index 72404d8..b089752 100644
--- c/.gitattributes
+++ i/.gitattributes
@@ -1,5 +1,4 @@
 * text=auto
-
 *.py    text eol=lf
 *.md    text eol=lf
 aliases text eol=lf
diff --git c/aliases i/aliases
index 8ee6e72..2a00600 100644
--- c/aliases
+++ i/aliases
@@ -159,3 +159,4 @@ alias tyrz_full="tyrz_sln && tyrz_build && tyrz_gen"
 alias wgnx_full="wgnx_sln && wgnx_build && wgnx_gen"
 alias wgny_full="wgny_sln && wgny_build && wgny_gen"
 alias wgnz_full="wgnz_sln && wgnz_build && wgnz_gen"
+test
diff --git c/bashrc i/bashrc
index feda536..86568d1 100644
--- c/bashrc
+++ i/bashrc
@@ -5,3 +5,4 @@ source aliases

 # Enable bash-style completion with argcomplete
 eval "$(register-python-argcomplete launchpy)"
+test
+ set +x

@dscho
Copy link
Member

dscho commented Sep 19, 2017

I fear that you will have to install Git for Windows' SDK, recompile Git using make in /usr/src/git/ after enabling debugging in gdb by creating the file config.mak with these contents:

DEVELOPER=1
CFLAGS := $(filter-out -O2,$(CFLAGS))
ASLR_OPTION := -Wl,--dynamicbase
BASIC_LDFLAGS := $(filter-out $(ASLR_OPTION),$(BASIC_LDFLAGS))

and then debugging in gdb, e.g. via gdb -args ./git status -v -v -v. You will want to set a breakpoint via b warn_on_inaccessible, then run via r and then at least look at the stacktrace via bt, or even go up and down between those frames and inspect the source code using the l command and the variables using p <variable-name>.

@pkonecki
Copy link
Author

Thanks, I'll try that and report my findings.

@pkonecki
Copy link
Author

Thread 1 hit Breakpoint 1, warn_on_inaccessible (path=0x3478e70 "") at wrapper.c:424
424             warning_errno(_("unable to access '%s'"), path);
(gdb) bt
#0  warn_on_inaccessible (path=0x3478e70 "") at wrapper.c:424
#1  0x00000000005cbe7c in warn_on_fopen_errors (path=0x3478e70 "") at wrapper.c:430
#2  0x00000000005cbec8 in fopen_or_warn (path=0x3478e70 "", mode=0x652045 <blank+313> "r") at wrapper.c:444
#3  0x00000000004b41b9 in read_attr_from_file (path=0x3478e70 "", macro_ok=1) at attr.c:723
#4  0x00000000004b4617 in bootstrap_attr_stack (stack=0x34dc660) at attr.c:876
#5  0x00000000004b472d in prepare_attr_stack (path=0x34dc7a0 "README.md", dirlen=0, stack=0x34dc660) at attr.c:915
#6  0x00000000004b4e8f in collect_some_attrs (path=0x34dc7a0 "README.md", check=0x34dc640) at attr.c:1112
#7  0x00000000004b4faf in git_check_attr (path=0x34dc7a0 "README.md", check=0x34dc640) at attr.c:1138
#8  0x00000000004d91d7 in convert_attrs (ca=0x111eef0, path=0x34dc7a0 "README.md") at convert.c:1039
#9  0x00000000004d9568 in convert_to_git (istate=0x6f7340 <the_index>, path=0x34dc7a0 "README.md", src=0x0, len=0, dst=0x0, checksafe=SAFE_CRLF_FALSE) at convert.c:1126
#10 0x00000000004e3c02 in would_convert_to_git (istate=0x6f7340 <the_index>, path=0x34dc7a0 "README.md") at convert.h:82
#11 0x00000000004eb9eb in reuse_worktree_file (name=0x34dc7a0 "README.md", oid=0x34dc750, want_file=0) at diff.c:2755
#12 0x00000000004ebd63 in diff_populate_filespec (s=0x34dc750, flags=0) at diff.c:2842
#13 0x00000000006090e5 in should_break (src=0x34dc750, dst=0x34dc7e0, break_score=30000, merge_score_p=0x111f1bc) at diffcore-break.c:64
#14 0x00000000006094d3 in diffcore_break (break_score=30000) at diffcore-break.c:181
#15 0x00000000004f284f in diffcore_std (options=0x111f7d0) at diff.c:5007
#16 0x00000000004e261b in run_diff_index (revs=0x111f2e0, cached=1) at diff-lib.c:519
#17 0x00000000005cfa57 in wt_status_collect_changes_index (s=0x6ad680 <s>) at wt-status.c:611
#18 0x00000000005cfea6 in wt_status_collect (s=0x6ad680 <s>) at wt-status.c:706
#19 0x0000000000424213 in cmd_status (argc=0, argv=0x1c2c38, prefix=0x0) at builtin/commit.c:1411
#20 0x000000000040276f in run_builtin (p=0x61a9a0 <commands+2400>, argc=4, argv=0x1c2c38) at git.c:342
#21 0x0000000000402ae6 in handle_builtin (argc=4, argv=0x1c2c38) at git.c:550
#22 0x0000000000402cd4 in run_argv (argcp=0x111fe00, argv=0x111fdb8) at git.c:602
#23 0x0000000000402fbe in cmd_main (argc=4, argv=0x1c2c38) at git.c:704
#24 0x000000000049ef04 in mingw_main (argc=5, argv=0x1c2c30) at common-main.c:43
#25 0x000000000049eebd in main (argc=5, argv=0x33e0498) at common-main.c:26
(gdb) p path
$2 = 0x3478e70 ""
(gdb) up
#1  0x00000000005cbe7c in warn_on_fopen_errors (path=0x3478e70 "") at wrapper.c:430
430                     warn_on_inaccessible(path);
(gdb) up
#2  0x00000000005cbec8 in fopen_or_warn (path=0x3478e70 "", mode=0x652045 <blank+313> "r") at wrapper.c:444
444             warn_on_fopen_errors(path);
(gdb) up
#3  0x00000000004b41b9 in read_attr_from_file (path=0x3478e70 "", macro_ok=1) at attr.c:723
723             FILE *fp = fopen_or_warn(path, "r");
(gdb) up
#4  0x00000000004b4617 in bootstrap_attr_stack (stack=0x34dc660) at attr.c:876
876                     e = read_attr_from_file(get_home_gitattributes(), 1);
(gdb) l
871                     push_stack(stack, e, NULL, 0);
872             }
873
874             /* home directory */
875             if (get_home_gitattributes()) {
876                     e = read_attr_from_file(get_home_gitattributes(), 1);
877                     push_stack(stack, e, NULL, 0);
878             }
879
880             /* root directory */

It seems git_attributes_file is not null but empty.
Looking at what xdg_config_home("attributes") does, it looks for env variables XDG_CONFIG_HOME (which is not set) and HOME which contains "/c/Users/eugen" (which is the right path to home)

I have an attributes file in ~/.config/git/, I tried moving it and testing again, same warning.
The file only contains "*.sav diff"

@pkonecki
Copy link
Author

pkonecki commented Sep 19, 2017

Okay I fixed it with

git config --global --unset core.attributesfile

It seems it was set to an empty value.

The global variable git_attributes_file was then set to an empty string at:

config.c:1027
if (!strcmp(var, "core.attributesfile"))
		return git_config_pathname(&git_attributes_file, var, value);

Thanks again for the help, don't know why the warning started showing since 2.14 though.

@dscho
Copy link
Member

dscho commented Sep 19, 2017

Cool, case closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants