Unable to create .bash_profile file and creating environmental variables in Mac

I have installedmongodb-osx-x86_64-enterprise-4.0.10 on my mac after that i tried searching for .bash_profile file which is not found to change the variables explained in course. when i tried creating one but it is not reflecting and not getting results while doing echo from terminal.

Are you able to see the file after you created
ls -lart .bash_profile

cd to your home dir
touch .bash_profile
edit the file and add your variables
save
then source/reload the file
. .bash_profile

Hi @Srivenkateswara_rao_76931,

Navigate to your home directory from the terminal and run the following command:

ls -a

You should see the file starting with .(dot) .bash_profile, meaning hidden file.

If you do not already have .bash_profile file, you can create it using instructions mentioned in the lecture: Installing the mongo shell(OSX/Linux).

Please let me know, if you have any questions.

Thanks,
Sonali

What if there is already a .bash_profile; however this is for another application, for e.g. # Setting PATH for Python 3.6. What should I do?

@Sonali_Mamgain I too am interested to know the answer to this, as typing echo $PATH leads to another bin.

Hi @Claudine_26798, @SB_78958,

You can add multiple paths to the PATH variable, seperating each path using colon(:).

Example:

export PATH = " < path to python bin>:< path to mongodb-enterprise-server bin>"

I hope it helps!!

Please let me know, if you have any questions.

Thanks,
Sonali

Hi @Sonali_Mamgain, Thank you for your response. I have tried both: export PATH=β€œ<path to mongodb-osx-x86_64-enterprise-4.0.10/bin>:$PATH” and export PATH=β€œ:<path to mongodb-osx-x86_64-enterprise-4.0.10/bin>”.
I used source between them, but the same path appears for anaconda. Do the files need repositioning?

Hi @SB_78958,

Positioning doesn’t affect the PATH variable.

Please share the screenshot of the .bash_profile file, so that I can give you more precise solution.

Thanks,
Sonali

Hi @Sonali_Mamgain, this is one of the bash_profile and bash screenshot:
export PS1=β€˜$ β€˜

export PATH=β€œ:<path to mongodb-osx-x86_64-enterprise-4.0.10/bin>”

HI @SB_78958,

From the terminal you can run the following command to update $PATH variable:

export PATH="/path to mongodb-osx-x86_64-enterprise-4.0.10/bin:$PATH"

Then run the following command to read the update made in above command:

source ~/.bash_profile

This should update your PATH.

Please let me know, if you still have any questions.

Thanks,
Sonali

1 Like

Thank you @Sonali_Mamgain. I followed your instruction, but it has not worked. It continues to refer to another .bash_profile file. Is there a way to private message you regarding the setbacks due to such issues?

I have the same problem. And after running source ~/.bash_profile it says export: `$’: not a valid identifier

Hi @SB_78958,

I would recommend you to follow lecture: Lecture: Installing the mongo Shell (OSX / Linux) as it shows how you can change path using file editor. It would be an easier approach.

Please let me know, if you still face any issues.

Thanks,
Sonali

Hi @Natalia_46973,

Please share the screenshot of your .bash_profile file.

Thanks,
Sonali

Thanks for your comments. i have done all but i got an error while using ’ or " in the bash file. I removed them and i just mentioned PS1=$, that works for me. Thanks for your help.

I had similar issue. I tried using with out ’ or " that works for me. Please try to use export PS1=$ . with no ’ or " and same for the path as well

Hi @Srivenkateswara_rao_76931
Thank you for the help. It worked with just export PATH="~/mongodb-osx-x86_64-enterprise-4.0.10/bin:$PATH"

Hi @Sonali_Mamgain

I resolved the issue,

Thank you

Yes, I am using this to do the setup. Stack Overflow does not have an article that has helped.
As I will not be able to complete the labs, it is better if I unregister from the course. How do I go about that?

Hi @SB_78958,

You can register for the next course offering and the next course starts from 16 Jul, 2019 17:00 UTC.

Good Luck!!

Thanks,
Sonali