0

I want to execute command gclient. I have already included its location in PATH. But I cannot directly execute it by command. Can someone tell me why?

~
❯ echo $PATH
/User/merle/depot_tools:/Users/merle/.nvm/versions/node/v11.10.0/bin:/usr/local/opt/mysql@5.5/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

~
❯ ls depot_tools | grep gclient
README.gclient.md
annotated_gclient.py
gclient
gclient-new-workdir.py
gclient.bat
gclient.py
gclient_completion.sh
gclient_eval.py
gclient_paths.py
gclient_scm.py
gclient_utils.py

~
❯ gclient
zsh: command not found: gclient

~
❯ cd depot_tools

~/depot_tools master
❯ ./gclient
Usage: gclient.py <command> [options]

Meta checkout dependency manager for Git.

Commands are:.......
Merle
  • 109
  • 1
  • 2
  • 9
  • The answer is already in your question: `./gclient [options]`, and the portion you didn't include that lists the commands. – Ken White Jul 17 '19 at 01:17
  • @KenWhite why does the `gclient` fail though (that's their original question) – zerkms Jul 17 '19 at 01:18
  • It doesn't fail when you use `./gclient`. This is a basic operating system requirement for any *nix based system, including MacOS. – Ken White Jul 17 '19 at 01:19
  • @KenWhite that directory is in the `$PATH`, you normally should not specify the absolute path or dot-started path for executables in the `$PATH` don't you – zerkms Jul 17 '19 at 01:20
  • @KenWhite Why can't I directly type "gclient" to execute the command? – Merle Jul 17 '19 at 01:22
  • It would be nice to see the output of `pwd` in the above, otherwise, how do we **know** the path is correct? without the output of pwd just before running the command with `./`, we are just *assuming* the path is correct. – GMc Jul 17 '19 at 01:56
  • 1
    Regardless, this belongs on [unix.se] or [SuperUser](https://superuser.com/). Stack Overflow is only for questions about *developing software*; configuring your shell, troubleshooting PATH lookups, &c. are outside that scope. – Charles Duffy Jul 17 '19 at 01:57
  • @GMc ~/depot_tools master ❯ pwd /Users/merle/depot_tools – Merle Jul 17 '19 at 02:05
  • @Merle, so as per my answer, your path is not correct. This is why you can not type the command directly at the command line without specifying a path in the command invovation. Hint - you are missing an S in User**s**. Can you accept my answer as being correct please? – GMc Jul 17 '19 at 02:07
  • @Merle : If you just type `gclient` with out a path, the system does not know in which directory to look for the program. But of course you can include `.` into your `PATH`. – user1934428 Jul 17 '19 at 06:50
  • @Merle : Also, why did you tag your question with `bash`, when bash is not involved. – user1934428 Jul 17 '19 at 06:52

3 Answers3

1

Take another look at your path:

export PATH=/User/merle/depot_tools:/Users/merle/...

Does your system contain just 1 User or multiple Users???

It should read:

export PATH=/Users/merle/depot_tools:/Users/merle/...
GMc
  • 1,764
  • 1
  • 8
  • 26
  • If this is true, the question should be closed as typo-based, not answered. See the "Answer Well-Asked Questions" section of https://stackoverflow.com/help/how-to-answer, the bullet point therein regarding "questions that are not about programming as defined in the help center", and #2 in the "some questions are still off-topic" list at https://stackoverflow.com/help/on-topic. – Charles Duffy Jul 17 '19 at 02:01
  • I do not see that option in the "flag" post function. (and I've already got too many "flagging is only if something needs to be drawn to a moderator" rejections) and those were for much more severe posts than just a typo (e.g. someone trying to promote his contracting services in an answer)! – GMc Jul 17 '19 at 02:04
  • ~/depot_tools master ❯ PATH=/User/merle/depot_tools:/Users/merle/ ~/depot_tools master ❯ gclient zsh: command not found: gclient – Merle Jul 17 '19 at 02:06
  • @Merle : Did you `export` your PATH? Also, `/Users/merle/ ~/depot_tools` doesn't make sense. You probably want `/Users/merle/depot_tools` or `/Users/merle:~/depot_tools`, depending on what you want to achieve. – user1934428 Jul 17 '19 at 06:54
  • 1
    @user1934428, updates to variables already in the environment are exported automatically. `export PATH` is redundant and unnecessary. – Charles Duffy Jul 17 '19 at 12:03
  • Correct, but from the posting, we can only see that PATH is defined. We can not see that it is exported. It could be that PATH was set initially without export - a rare situation, but not impossible. – user1934428 Jul 18 '19 at 03:29
1

i think you may forget

source ~/.nvm/nvm.sh

if you want automatically load it ,there are two ways

open ~/.zshrc 

1.add

source ~/.nvm/nvm.sh

2.or add

export NVM_DIR="/Users/YOUR_USER_NAME(you need use you user name)/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

hope this can help you

Cognia
  • 437
  • 3
  • 10
0

ZSH: command not found

The Problem was .zshrc, it was missing. the solution which worked for me :

You have to create a .zshrc file. to create use "vim .zshrc" command then insurt your path "export PATH="$PATH:pwd/flutter/bin"

save and completely exit your terminal completely. install gem cocoa pods then accept the license. you are good to go.

  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 23 '21 at 06:52