How to install AWS SAM Local on Ubuntu 16.04? - amazon-web-services

I am trying to install AWS SAM (Serverless Application Model) Local on Ubuntu 16.04.
I tried to install SAM Local using NPM with the following command.
npm install -g aws-sam-local
I got the following error.
Please help me to sort it out?

Installation on Ubuntu 16.04/18.04
sudo apt-get install python3-pip -y
sudo -H python3 -m pip install aws-sam-cli

First try
npm config set unsafe-perm=true
I also installed node v8.11.1

The standard shebang for node is #!/usr/bin/env node. There is a package conflict with the name node, so it's named nodejs.
You can solve the issue with a symlink using alternatives.
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

first try
npm install -g go-npm
then
npm install -g aws-sam-local

If issue with current user permissions, please use sudo with below commands
First try,
npm config set unsafe-perm=true
Then,
npm install -g go-npm
finally,
npm install -g aws-sam-local
It will also work for mac.

Related

AWS CDK python client giving error with cdk deploy

My stack:
python 3.6
Node.js 11.3.0
jsii-0.20.11 (automatically installed when aws cdk is installed via npm)
I just tried cdk init and then did pip install -e.
After that, I did cdk deploy and it gives me the following error:
Traceback (most recent call last):
File "app.py", line 3, in <module>
from aws_cdk import core
File "C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\aws_cdk\core\__init__.py", line 1967, in <module>
class DependableTrait(metaclass=jsii.JSIIAbstractClass, jsii_type="#aws-cdk/core.DependableTrait"):
TypeError: __new__() got an unexpected keyword argument 'jsii_type'
Subprocess exited with error 1
(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>
(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>fs.js:122
throw err;
^
Error: EOF: end of file, read
at Object.readSync (fs.js:517:3)
at SyncStdio.readLine (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13350:25)
at InputOutput.read (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13300:34)
at KernelHost.run (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7231:32)
at Immediate.setImmediate (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7239:37)
at processImmediate (timers.js:632:19)
It usually means some kind of versions missmarch: aws-cdk in npm and aws-cdk in python. Given that it's a pretty old question I suppose updating all packages or even reinstall the environment should help.
There are mentions of a similar problem in the official aws-cdk bug tracker:
https://github.com/aws/aws-cdk/issues/3349
https://github.com/aws/aws-cdk/issues/3293
I agree, this is frustrating and hard to find a fix for. Using the links from #Trilliput
My Steps:
Uninstall pip
Update homebrew
Remove the aws cli
Reinstall the aws cli
uninstall aws cdk
reinstall aws cdk
Commands:
sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
pip3 uninstall aws-cdk.cdk
pip3 install aws-cdk.cdk --use-feature=2020-resolver
That didn't work as I hoped, so I used all of these commands below. I called it to scorched earth reinstall:
sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
brew uninstall node
brew uninstall pyenv
# CLOSE your terminal window and open a NEW terminal window.
# when you run [which python] you should get /usr/bin/python
# run these commands to remove node and npm
https://gist.github.com/TonyMtz/d75101d9bdf764c890ef
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python3 get-pip.py
brew install python3
# old CDK
pip3 uninstall aws-cdk.cdk
#new CDK
pip3 uninstall aws-cdk.core
# NEW CDK
pip3 install aws-cdk.core
#pip3 install aws-cdk.core --use-feature=2020-resolver
# reinstall aws cdk
npm install -g aws-cdk
npm install -g npm#7.0.13
sudo npm install -g npm#7.0.13
npm install -g aws-cdk
sudo npm install -g aws-cdk
sudo -i
sudo npm install -g aws-cdk
cdk --version
Bumping up the python version from 3.6 to 3.7.5 worked like a charm for me

-bash: aws: command not found

I'm on macOS Mojave Version 10.14.5.
I was following the instructions here
Installing the AWS CLI
when I got to the part to type
aws --version
in terminal, and got the response
-bash: aws: command not found
Here's a screenshot of terminal
I looked at the other posts similar to this on stackoverflow, but they seem to apply to different contexts. They have not helped.
you need to install python and pip on your mac in order to install the awscli.
After the installation of python and pip, please use following command to install aws cli with latest version from AWS.
sudo pip install awscli --force-reinstall --upgrade
Install python version 3 or higher And Use this command to download aws cli with python3
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo /usr/local/bin/python3 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
use AWS official guide here to ensure you are installing the latest version.
I have mac and this fixed the issue
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
This command works good for me
sudo apt install awscli

Dockerfile fails with install forever

I'm running a docker and its construction fails with this output messsage:
docker.errors.BuilError: The command '/bin/sh -c apt-get install npm'
returned a non-zero code: 1
Dockerfile has this code:
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y software-properties-common
RUN apt-get install -y nodejs
RUN apt-get install npm
RUN npm install forever -g
Otherwise I can correctly execute the same commands just directy at command line outside docker's construction, and on Ubuntu 14:04.
Also I've runned another version of dockerfile without this commands, and it constructs dockers correctly.
Can you help me, please?
Thanks a lot.
I think you must pass the '-y' flag on install npm since it means 'yes' to apt-get prompt. If you look closely the other install commands already have it.

How to uninstall aws-cli

I am trying to set up an "Amazon Elastic Container Registry" but I get the following error when using this command: aws ecr get-login --no-include-email --region us-west-2:
Unknown options: --no-include-email
The manual redirects me when this occurs to go to the following page, in order to update my aws cli. https://docs.aws.amazon.com/cli/latest/userguide/installing.html
Which in short means, call pip install awscli --upgrade --user. While that works, my cli is not updated. So I removed it at all pip uninstall awscli. But I still had the aws command available, also when I opened a new session in the terminal...
So I assume I haven't installed my aws cli via pip, but I can not figure out how it does is installed. Can anyone help me out and give me some directions to resolve this issue. So I can remove the current awscli, and install a new version via pip install awscli --upgrade --user
I had a similar issue. Answering in case someone else does too. I think I had originally installed it without pip like this:
https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html.
So you just need to uninstall it like this (as instructed in above link):
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
Then you can re-install it with pip3:
https://docs.aws.amazon.com/cli/latest/userguide/cli-install-macos.html
Basically:
pip3 install awscli --upgrade --user
Then add it to your path
export PATH=/Users/yourname/Library/Python/3.6/bin/:$PATH
On ubuntu :
sudo apt-get remove --auto-remove awscli
ln -s /home/ubuntu/.local/bin/aws /usr/bin/aws
Uninstall awscli.
pip uninstall awscli -y
I had the same issue, but unlike Morgan, I prefer to use Homebrew to maintain all my dependencies in a single place.
So what I did was:
1 - uninstall awscli (was installed with pip - python2)
$ sudo rm -rf /usr/local/aws
$ sudo rm /usr/local/bin/aws
2 - Install awscli using homebrew
$ brew install awscli
Homebrew will install awscli inside Cellar folder: /usr/local/Cellar/awscli
Note: I also have python3 installed through Hombrew.
Links:
Amazon-awscli: Amazon Install awscli
Homebrew-awscli: Homebrew Install awscli
Homebrew-python3: Homebrew Install python3
If you are using mac and used brew to install aws cli. Use brew uninstall awscli and try brew install awscli
First try to get the path of the installation by using this command in Linux or mac
which aws-cli
After you get the installation location try removing the directory by using
sudo rm -rf "/path resultant from previous command"
In case if someone has installed aws-cli using Snap,then following method might be helpful :
First, open the Linux terminal and run the following command in it:
sudo snap remove aws-cli
The basic command line to remove a snap package is
sudo snap remove < package >
You have to put the name of a specific application instead of < package >
Once you execute the command successfully, the terminal will ask you to enter the [sudo] password you put for the installation, but if you don’t have any password, press Enter to process it.
After completion of this procedure, you will see that aws-cli gets uninstalled from the system. However, the folder of aws is still present in the snap folder, so execute the following command to remove it:
sudo snap rm -r aws-cli
Remove respective bin & config files:
rm -rf /usr/local/bin/saml2aws
rm -rf ~/.aws/config
rm -rf ~/.aws/credentials
Reinstall using the 'install.sh' script
I tried this on linux and it seemed to work
sudo yum erase awscli
and get me to a place where when I run:
aws --version
zsh: command not found: aws

gulp: command not found

when i run gulp in cmd it says gulp: command not found
though when i checked
npm root (Path Local)
/var/www/html/gus/node_modules
npm root -g (Path Global)
/Users/zohaib/npm-global/lib/node_modules
i followed these rules though these are for OsX and im having ubuntu 16.04
To install gulp in Ubuntu, mentioned below are the steps:
sudo apt-get install node
sudo apt-get install npm
sudo npm install --global gulp
sudo apt-get install nodejs-legacy
sudo npm install
Then run gulp.