Search code examples
mongodbpathterminalrootcd

Why can't I access my vi folder?


I keep getting this error on my terminal which stops me accessing the vi folder. I've been trying to set a path to the MongoDB bin and when experimenting on how to do this, I think I've broken the folder. Can someone please help?

Last login: Mon May 18 10:31:54 on console
-bash: export: `/Users/james.flan/Documents/Software/MongoDB/bin :/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin': not a valid identifier
AMAC02MX3APF8J3:~ james.flan$ cd
AMAC02MX3APF8J3:~ james.flan$ vi .bash_profile
-bash: vi: No such file or directory
AMAC02MX3APF8J3:~ james.flan$ 

Expanded:

AMAC02MX3APF8J3:~ james.flan$ cat ~/.bash_profile
-bash: cat: No such file or directory
AMAC02MX3APF8J3:~ james.flan$ 
AMAC02MX3APF8J3:~ james.flan$ /bin/cat ~/.bash_profile
export PATH= "/Users/james.flan/Documents/Software/MongoDB/bin :$PATH"
AMAC02MX3APF8J3:~ james.flan$ 

Solution

  • The problem is with your $PATH variable. You have broken it, so bash does not find any utility out of your current working directory.

    To fix your issue you can execute vi directly with the absolute path:

    $ /usr/bin/vi ~/.bash_profile
    

    Then edit your $PATH declaration line:

    export PATH="/Users/james.flan/Documents/Software/MongoDB/bin:$PATH"
    

    Then you can either start a new Terminal session, or in the same session do:

    $ /bin/bash -l