Saturday, July 27, 2019

amazon web services - adding the aws executable to your OS's PATH environment variable: needed every time?




I am following the install directions outlined in this article (https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html#awscli-install-linux-path)to install the AWS CLI on a Raspberry Pi.

(OS: PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)")



The steps are pretty straightforward though I am running into a problem with the section called "Adding the AWS CLI Executable to your Command Line Path"



Following the instructions I determined that I need to run the following two commands to complete this step:



$ export PATH=~/.local/bin:$PATH
$ source ~/.profile



once I do this I can run $ aws and I see the following message as expected:



usage: aws [options]   [ ...] [parameters]
To see help text, you can run:

aws help
aws help
aws help
aws: error: too few arguments



All good so far. If I close my terminal and then re-open a new terminal and I try to run an command starting with aws I get the following:



bash: aws: command not found


I have found that if I re-run the following...



$ export PATH=~/.local/bin:$PATH
$ source ~/.profile



... then it works again... until I close my terminal window.



So my question is:



Is this expected behavior, to have to re run these commands every time I want to work with the AWSCLI? Or should this step be a do-once-and-done. I admit I don't know very much about the nature of these commands, or what they are trying to achieve.


Answer



This is expected behaviour of export and source. You will find yourself doing the same thing for other programs as well, not just aws-cli.




A better way would be to edit the ~/.profile file and add export PATH=~/.local/bin:$PATH at the end of file.



Every time you open a new shell session, the .profile file is loaded, and the export will be run.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...