Cloud Functions Emulator: Unable to deploy functions - google-cloud-functions

I am trying to deploy my functions on the cloud functions emulator but my terminal throws me this error:
$ functions deploy sendNotifications --trigger-http
{ Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#google-cloud/functions-emulator/logs'
at Error (native)
at Object.fs.mkdirSync (fs.js:922:18)
at Object.assertLogsPath (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/emulator/logs.js:31:10)
at new Controller (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/controller.js:84:32)
at Object.exports.handler (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/commands/deploy.js:124:22)
at Object.self.runCommand (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/lib/command.js:231:22)
at Object.Yargs.self._parseArgs (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/yargs.js:989:30)
at Object.Yargs.self.parse (/usr/local/lib/node_modules/#google-cloud/functions-emulator/node_modules/yargs/yargs.js:533:23)
at Object.main (/usr/local/lib/node_modules/#google-cloud/functions-emulator/src/cli/main.js:69:6)
at getProjectId.then (/usr/local/lib/node_modules/#google-cloud/functions-emulator/bin/functions:100:27)
errno: -13, code: 'EACCES', syscall: 'mkdir', path:
'/usr/local/lib/node_modules/#google-cloud/functions-emulator/logs' }
I have cd-ed to the functions directory and checked that I am logged in to firebase and selected the right project Id. Am i doing something wrongly?

Overview
The proper way to fix this is by changing the npm global directory to one that does not require root permission to install and run.
You really should not be requiring sudo to npm install -g.
Likewise to functions start.
Cleansing
Given that you have installed functions, presumably using sudo npm install -g #google-cloud/functions-emulator, you now need to first uninstall it equally with sudo: sudo npm uninstall -g #google-cloud/functions-emulator.
Why uninstall it? You currently have functions installed into a directory where root permissions are required to write. It does require write permission to log file as you can see from the error.
I would suggest uninstalling the other npm packages which you may have installed using sudo, except npm. You can find out what you have using sudo npm list -g --depth=0.
Changing npm global directory
I would suggest going with Option 2 described on https://docs.npmjs.com/getting-started/fixing-npm-permissions
Copy pasting solution from link above:
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
source ~/.profile
Install global without sudo
Now that your machine has been cleansed and npm global has been configured to a directory that does not require root permissions, you should be able to install and run without sudo.

Had the same issue. For me it did not showed the permission log also..The issues is with the permissions. Try to the command with super user.
Step 1.
Start the gcloud functions
sudo functions start
Step 2.
Deploy the helloworld function which was exported.
sudo functions deploy helloworld --trigger-http

This is obviously very late for the original post. Hope this helps other who has the same error in the future.
I had the same issue turn out I hadn't installed that the requirements properly. Any one who steps in here can look at Error: EACCES: permission denied #195.
Main note of this error install all requirements properly.

Related

How do you add chmod +x permission to an AWS Elastic Beanstalk platform hook?

Context
I am using Elastic Beanstalk to deploy a very simple test application. I have several packages I want to install using apt. I have included a 01_installations.sh script with the installations in the .platform/hooks/prebuild directory. When I zip my application and deploy to Elastic Beanstalk, the logs confirm that the prebuild script runs, but it does not have permissions.
2020/08/12 21:03:46.674234 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/12 21:03:46.674256 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/08/12 21:03:46.674296 [INFO] Following platform hooks will be executed in order: [01_installations.sh]
2020/08/12 21:03:46.674302 [INFO] Running platform hook: .platform/hooks/prebuild/01_installations.sh
2020/08/12 21:03:46.674482 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/01_installations.sh failed with error fork/exec .platform/hooks/prebuild/01_installations.sh: permission denied
Question
My understanding is that permissions were denied because I did not add chmod +x to make the .sh file executable. As the AWS documentation on platform hooks states: "Use chmod +x to set execute permission on your hook files." (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html). My question is: how do I do this?
I simply have the .sh file in a directory. I do not call it from anywhere else. Is there a simple step I'm missing? The AWS documentation makes it seem like it should be straightforward.
Previous Attempts
Things I have tried:
Adding .ebextensions
Attempt: Create a .config file in the .ebextensions directory with the below command which should execute the .sh file with chmod +x permissions.
Result: The same error occurs. The Elastic Beanstalk logs do not indicate that the .config was processed at all.
container_commands:
01_chmod1:
command: "chmod +x .platform/hooks/prebuild/01_installations.sh"
Changing the name of the .sh file
Attempt: Change the .sh file to be named "chmod +x 01_installations.sh" as suggested by an AWS user (forums link below). Remove the .ebextensions
Result: The same error occurs.
[RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/chmod +x 01_installations.sh failed with error fork/exec .platform/hooks/prebuild/chmod +x 01_installations.sh: permission denied
I have reviewed the ideas here, but none of them actually include complete enough examples to follow:
https://forums.aws.amazon.com/thread.jspa?messageID=942515
https://github.com/aws/elastic-beanstalk-roadmap/issues/15
Make sure to make your file executable in git
chmod +x path/to/file
git update-index --chmod=+x path/to/file
reference from
How to add chmod permissions to file in GIT?
Normally you set the permissions on your local workstation, when before you zip your deployment package.
However, if you want to do this on EB instance, then you can't use container_commands for that. The reason is that container_commands execute after prebuild. Instead you should try using commands:
The prebuild files run after running commands found in the commands section of any configuration file and before running Buildfile commands.
This worked for me after updating the permission commit the changes.
Also the commands in .config file will not work as those commands will run pre-deployment and hence will not be able to find the path to .sh file.

Composer Self-Update Error Exception "Permission Denied" when calling rename()

So, whenever i run composer self-update or composer selfupdate I get the following error:
[ErrorException]
rename(/Users/jrobinson/.composer/cache/composer-temp.phar,/usr/local/bin/composer): Permission denied
I'm not too sure what's going on. I THINK i may had screwed up my .bash_profile file up. I wasn't having this issue prior to installing MySQL on my machine, and updating the first line in my .bash_profile.
I have looked at other articles, and I have tried reinstalling using the getcomposer.org commands on their download page. None of these solutions have fixed my problem. So please don't mark this as a repeat question as none of the solutions on SO have helped me solve this issue.
Here is my .bash_profile file contents.
export PATH="~/.composer/vendor/bin:$PATH:/usr/local/mysql/bin"
export EDITOR='sub -w'
Here is the ls -la command run in the /usr/local/bin folder.
Goal
Be able to run the composer self-update command and the mysql command from my terminal at the end of all this.
It looks like Composer is installed in /usr/local/bin, so you probably did that as root. To update it, you also need to be a root - try with sudo:
sudo -H composer self-update

Error on installing contrib module to ejabberd

Following the instructions at https://github.com/processone/ejabberd-contrib I try running:
ejabberdctl module_install ejabberd_auth_http
But the response I get is:
Error: not available
Do I need to download the module to a specific place in the ejabberd install path for this to work, or is there some other step missing?
I tried the following sequence on ejabberd and it seems at least to install:
Make sure ejabberd is started
$ ./ejabberdctl start
Download the list of available modules:
$ ./ejabberdctl modules_update_specs
Check available modules:
$ ./ejabberdctl modules_available
Install the module:
$ ./ejabberdctl module_install ejabberd_auth_http
src/ejabberd_auth_http.erl:11: Warning: behaviour ejabberd_gen_auth undefined
ok
From there you should be able to configure it and restart ejabberd.
Reference: Easy installer and structure for ejabberd contributed modules

Error running mysql_install_db: could not find ./bin/my_print_defaults

I seem to be having an issue getting MySQL 5.6.1.5 to install from Source. I am running RHEL 6.
I was able to perform the cmake, make, and make install without issues.
I am attempting to run the mysql_install_db binary and when I do I get the following error:
Fatal ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to copy the software
into the correct location ready for operation.
If you are using a binary release, you must either bat at the top level of the
extracted archive, or pass the --basedir option pointing to that location.
So I did a check for my_print_defaults using which my_print_defaults, unfortunately it was not found on my machine.
I did a locate my_print_defaults as well just for the heck of it and said it was located in /usr/bin/my_print_defaults, however, when I checked /usr/bin for the binary, it was not actually there.
I would try to use mysql_install_db --basedir=/usr/bin but I know this won't work as the which and locate commands confirm my_print_defaults isn't on my machine.
I looked at mysql_install_db giving error, but that error was not similar to this one.
Please ignore question, I didn't bother to try running find / -name my_print_defaults and found it in /usr/local/mysql/bin/
I searched packages for my_print_defaults with
apt-file search my_print_defaults
If my_print_defaults is missing on your system (which my_print_defaults), first find out which db is installed with:
dpkg -l |grep -E 'maria|mysql'|grep ii|grep server
If you have installed mariadb, try reinstall mariadb:
sudo apt install --reinstall mariadb-server-core-10.1
If you don't find a solution with mariadb, swap back to mysql with
sudo apt install mysql-server

Nupic Installation Ubuntu 13.04

I am having a heck of a time installing NUPIC on ubuntu-13.04-desktop-amd64.iso [within Exsi 5.1].
I've followed the instructions on https://github.com/numenta/nupic/wiki/Install-Nupic-on-ubuntu-13.04. The install fails at:
pip install -r external/common/requirements.txt
with the following error:
error: could not create '/usr/local/lib/python2.7/dist-packages/asteval': Permission denied
It works if I use sudo pip install... but just fails on
$NUPIC/build.sh
I also had to add
sudo apt-get install python-dev
sudo apt-get install python-numpy
to even get it to the "pip install..." point.
Any assistance would be appreciated.
Thanks,
Neil
I had the same problem trying to install nupic.
I was following these instructions:
https://github.com/numenta/nupic/wiki/Running-Nupic-in-a-Virtual-Machine
The problem you may be facing is that your user does not have read/write access to the /usr/local/lib/python2.7/dist-packages/asteval folder. You can use the chown command to change that folders ownership to the user you want and give that user read/write access.
With regards to the above instructions, I installed using sudo but failed to realize that the environment variables for root were different than the environment variables for the user I created to install nupic.
Hope this helps,
VS
Thank you for the report. I've created a ticket to address this installation issue.
Neilg, please try these instructions: https://github.com/numenta/nupic/wiki/Installing-NuPIC-on-Ubuntu
The problem you may be facing is that your user does not have read/write access to the /usr/local/lib/python2.7/dist-packages/asteval folder. You can use the chown command to change that folders ownership to the user you want and give that user read/write access.
YOU NEED TO ADD THE OPTION --user after pressed commands