progit / progit2

Pro Git 2nd Edition
Other
5.87k stars 1.93k forks source link

git: 'credential-read-only' is not a git command #1969

Closed Sherry520 closed 2 months ago

Sherry520 commented 3 months ago

There's no existing/similar bug report.

This report is about a single actionable bug.

This report is about the ProGit book, version 2, English language.

Bug covers book website/pdf

Problem is present in the Pro Git book on the website?

Which version of the book is affected?

Source files

Describe the bug:

In section "Git Tools" -> "Credential Storage" -> "A Custom Credential Cache" When I run the command git credential-read-only --file=./ get , error occured: git: 'credential-read-only' is not a git command. See 'git --help'.

Steps to reproduce:

  1. vim git-credential-read-only

  2. paste the following code as show in section "Git Tools" -> "Credential Storage" -> "A Custom Credential Cache" image

  3. export PAHT=~:$PATH

  4. git credential-read-only --file=git.store get

  5. See error image

Expected behavior:

In my case, it doesn't show the input and occurred error.

image

Screenshots:

No response

Additional context:

No response

Device

No response

Operating system

No response

Browser/application + version

No response

Sherry520 commented 2 months ago

When I read this section 10-git-internals/sections/environment.asc, I know why there is this error, and what I really need to do is change the environment variable GIT_EXEC_PATH, not PATH. Therefore, I recommend revising this section and stating in advance that this will be covered in more detail in subsequent chapters.

ben commented 2 months ago

In your reproduction, you typed this:

export PAHT=~:$PATH

Is this typo the source of your issue? Because I'm able to do this:

$ echo $PATH
# (includes ~/bin)
$ cat > ~/bin/git-test-command
#!/bin/sh
echo hello git
^D
$ chmod a+x ~/bin/git-test-command
$ git test-command
hello git
$ 
Sherry520 commented 2 months ago

@ben Yes, it's weird. Now I can modify PATH to run the commend without modifying GIT_EXEC_PATH, maybe because I didn't have ruby installed before. But now there's another error, unless I change File.exists? to File.exist?. image

ben commented 2 months ago

Yup, looks like File.exists? was deprecated in Ruby 2.2, and removed in Ruby 3.2. You probably ended up with a 3.3 Ruby. If you'd like to submit a PR that fixes that line I'd accept it.