Adding Environment Variables

bashterminal

I can't understand the 3rd line in these instructions, found here

  1. Install dependency Ghostscript. On MacOSX: brew install ghostscript
  2. Create a symbolic link if you want to run it everywhere in bash ln -s pdf_creator.py pdfc
  3. Add in PATH environment variable On MacOSX: echo export=/absolute/path/of/the/folder/script/:$PATH >> ~/.bash_profile

What path are they talking about? The path where the ghostcript is? I don't know where that would be. When I ran echo export=/absolute/path/of/the/folder/script/:$PATH in terminal, nothing happened to the bash profile.


Update

  • Placed the folder pdfc_master which contains the file pdf_compressor.py in /users/bobsmith/codes/pdfc_master/pdf_compressor.py

  • Run ln -s /users/bobsmith/codes/pdfc_master/pdf_compressor.py pdfc

  • Run echo export=/users/bobsmith/codes/pdfc_master/pdf_compressor.py/:$PATH >> ~/.bash_profile

I now have the following syntax on my bash_profile

export=/users/bobsmith/codes/pdfc_master/pdf_compressor.py/:/Users/bobsmith/codes/venv/bin:/usr/local/opt/tcl-tk/bin:/Users/bobsmith/Applications/miniconda3/condabin:/Users/bobsmith/.pyenv/shims:/Library/Frameworks/Python.framework/Versions/3.7/bin:/applications/google-cloud-sdk/bin:/usr/local/opt/openssl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/PycharmProjects/book/superlists/chromedriver:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

That looks wrong to me.

So I then ran in terminal:

pdfc /users/bobsmith/downloads/montale_eng3.pdf 0 /users/bobsmith/downloads/montale_eng2.pdf

And I got the error pdfc not found. I would think that pdfc would have to be somewhere in my bash_profile but it is not.

Best Answer

No, it is the path where you have created the pdfc symbolic link.

The command you ran was incomplete - you need to first replace /absolute/path/of/the/folder/script/ with the actual path to the pdfc symbolink link. In addition you must use the full command including >> ~/.bash_profile in order to actually get something saved in the bash profile.

Also, the 3rd line you quote is just wrong (also in Github itself), it should be

echo 'export PATH="/absolute/path/of/the/folder/script/:$PATH"' >> ~/.bash_profile

As you have already run the wrong command you'll need to edit your .bash_profile manually (e.g. with nano) to fix the wrong definition. Either source .bash_profile afterwards or open a new Terminal tab/window to load the new value.