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

no such file or directory: ../../usr/local/bin/git #61

Closed
tekumara opened this issue Dec 12, 2021 · 3 comments · Fixed by #63
Closed

no such file or directory: ../../usr/local/bin/git #61

tekumara opened this issue Dec 12, 2021 · 3 comments · Fixed by #63
Labels

Comments

@tekumara
Copy link

tekumara commented Dec 12, 2021

When in the directory /tmp/setup on the master branch:

$ git checkout testing-image
(eval):1: no such file or directory: ../../usr/local/bin/git
$ which -a git
git () {
	case $1 in
		(commit | blame | log | rebase | merge) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")" ;;
		(checkout | diff | rm | reset) eval "$(scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" "$@")" ;;
		(add) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")"
			scmpuff_status ;;
		(*) "$SCMPUFF_GIT_CMD" "$@" ;;
	esac
}
/usr/local/bin/git
/usr/bin/git

This works without error:

/usr/local/bin/git checkout testing-image
@mroth
Copy link
Owner

mroth commented Dec 12, 2021

Hmm. Strange. Thanks for the bug report. Some questions:

  1. What is your operating system and version?
  2. What is your shell and version?
  3. Does this only happen when you are in the /tmp/setup directory, or does it occur with all repositories?
  4. If sounds like $SCMPUFF_GIT_CMD is somehow not properly set. If you get in that state, what does echo $SCMPUFF_GIT_CMD output? (From looking at your other output, I'm guessing it will return ../../usr/local/bin/git -- which would be indicative of a problem being a relative path rather than absolute -- but I want to confirm this before debugging further.)

Thanks!

@tekumara
Copy link
Author

Thanks for taking a look!

  1. macOS Big Sur 11.6.1 (20G224)
  2. $ zsh --version
    zsh 5.8 (x86_64-apple-darwin20.1.0) 
    
  3. Only in subdirs of /tmp but with any repo
  4.  $ echo $SCMPUFF_GIT_CMD
     /usr/local/bin/git
    

@mroth
Copy link
Owner

mroth commented Dec 13, 2021

Okay, I think I've tracked this down. It's quite weird.

  1. Under the hood the scmpuff's shell wrapper for git checkout is evaling a command which uses scmpuff expand --relative. scmpuff expand --relative takes absolute paths and converts them to relative. As we can see below, it's doing this for the $SCMPUFF_GIT_CMD as well when it is an absolute path, which is probably undesired.
$ export e1=~/src/scmpuff/scripts/benchmark.sh

$ scmpuff expand  -- git blah 1 
git	blah	/Users/mroth/src/scmpuff/scripts/benchmark.sh

$ scmpuff expand --relative -- git blah 1
git	blah	scripts/benchmark.sh

$ scmpuff expand --relative  -- /usr/bin/git blah 1
../../../../usr/bin/git	blah	scripts/benchmark

I suspect since $SCMPUFF_GIT_CMD was simply git in the integration test environment I never noticed this?

Now, normally this wouldn't cause execution problems, but...

  1. /tmp on macOS is actually /private/tmp, in a way that confuses filepath.Rel() in Go. See gs a bit confused in /tmp #31 and Inconsistent relative paths with symlinks in scmpuff expand #11 for additional context. Normally this isn't an issue (the messy paths resolve fine for files), but seems to be causing an issue for finding the git binary here. I believe the switch to scmpuff exec as default in RFC: scmpuff exec #49 may make this irrelevant when released, but I'd like to fix the underlying issue anyhow.

@mroth mroth added the bug label Dec 13, 2021
@mroth mroth closed this as completed in #63 Dec 16, 2021
mroth added a commit that referenced this issue Dec 16, 2021
Fixes #61, where in certain cases the path to SCMPUFF_GIT_CMD was being converted from an absolute path to a relative path, causes issues in certain filesystem traversal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants