0

I'm trying to install Mongo but having trouble with the $PATH var in MacOS. Following the guidelines. My $PATH is set in .bash_profile:

 export PATH=/Users/evl/dev/mongodb/bin⁩:$PATH

which works:

echo $PATH
/Users/evl/dev/mongodb/bin⁩:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

entering mongo on command line from other directory:

:~ evl$ mongo
-bash: mongo: command not found

I expected that mongo would be found now the $PATH is set

entering ./mongo on command line from mongo bin directory:

cd /Users/evl/dev/mongodb/bin⁩
./mongo
MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017

So now mongo runs. But only if I move to the folder and I enter './mongo'.

I would expect with the $PATH variable set correctly, the executable would run from any directory. It should actually. What is going wrong? Any help is appreciated!

8
  • 1
    Have you restarted Terminal or tried in a new shell? I assume you aded the export $PATH to ~./bash_profile or ~/.bashrc
    – mmmmmm
    Nov 1, 2018 at 11:45
  • @Mark If echo $PATH shows the new path the environment seems to be correct.
    – nohillside
    Nov 1, 2018 at 11:52
  • 1
    What is the output of running type -a mongo.
    – Nimesh Neema
    Nov 1, 2018 at 11:56
  • @nohillside not if just entered in current session. bash caches the items on the PATH so needs rehash or a new shell
    – mmmmmm
    Nov 1, 2018 at 12:54
  • $ type -a mongo -bash: type: mongo: not found Nov 1, 2018 at 17:26

1 Answer 1

1

I just typed everything again, exactly the same as before, but no copy-paste, and now the issue was gone. Some strange characters, invisible, might have shifted in .. Weird.. but happy to continue now..

You must log in to answer this question.

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