2

If I type dart in my terminal, this will access my dart terminal app. What does this point to and where can I change it?

My $PATH variable is as follows:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/[USERNAME]/installs/flutter/bin:/Users/[USERNAME]/installs/connectIqSDK/bin
5
  • 1
    type dart will show you the path to the binary. Not sure what you mean by "changing it". Can you please clarify and also add how exactly you installed dart in the first place?
    – nohillside
    Dec 11 '19 at 11:17
  • Thank you @nohillside, so there is a dart sdk included in flutter and a dart sdk installed by brew. I would like to use the dart binary that is included in the flutter install directory. Currently the dart command is pointing to the one installed in (/usr/local/bin/pub) and I would like to point it to ~/installs/flutter/bin/cache/dart-sdk/bin/dart
    – atreeon
    Dec 11 '19 at 11:29
  • actually it is the pub command I would like to change, not the dart command (sorry, I'm a bit new to macs, I think in windows it is just an environment variable change...not too sure though)
    – atreeon
    Dec 11 '19 at 11:30
  • 1
    Please edit your question to ask what you actually want to know. Also run echo $PATH in Terminal and add the result to the question.
    – nohillside
    Dec 11 '19 at 11:32
  • 2
    PS: Matter of terminology: A command isn't pointing to a path, it is installed in a directory (/usr/local/bin and ~/installs/flutter/bin/cache/dart-sdk/bin in your case).
    – nohillside
    Dec 11 '19 at 11:33
3

You can find the path to a binary by using type:

$ type latex ruby dart
latex is /Library/TeX/texbin/latex
ruby is /usr/bin/ruby
-bash: type: dart: not found

To use a version of a binary stored somewhere else you can

  • use the full path when calling it: ~/installs/flutter/bin/cache/dart-sdk/bin/dart
  • define an alias (won't work in scripts): alias dart=~/installs/flutter/bin/cache/dart-sdk/bin/dart
  • adjust PATH: PATH=~/installs/flutter/bin/cache/dart-sdk/bin:$PATH
4
  • You can also use which, e.g.: which latex ruby dart Aug 25 '20 at 18:01
  • @user3439894 which is aliased to 'type -p', at least in Bash :-)
    – nohillside
    Aug 25 '20 at 18:05
  • 1
    On my system, running macOS High Sierra, which which returns /usr/bin/which and ls -l /usr/bin/which returns -rwxr-xr-x 1 root wheel 18576 May 29 2018 /usr/bin/which and this is a binary executable, not a symlink to type. Aug 25 '20 at 18:22
  • @user3439894 Right you are. And here I sit now, wondering why I added an alias for this in my .bashrc.
    – nohillside
    Aug 25 '20 at 18:28
3

You can use the builtin type command with -a option to display all locations containing an executable named NAME.

So, to find all the locations in the PATH variable that points to the executable named dart, you can type:

type -a dart

Running type command without -a option would only display the first match found in the PATH.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .