Getting permission denied when running cf command on mac os x

I installed the Cloud Foundry CLI package on my Mac OS X Yosemite. From the terminal interface, when I type cf command, I get the following error

 FAILED Error read/writing config: open /Users/viyer/.cf/config.json: permission denied 

How to fix it? I can not find the config.json file.

+6
source share
7 answers

I found that removing the .cf directory and then running cf cli fixed it

 sudo rm -r ~/.cf cf -h 
+10
source

It was a bit strange, but I solved it by assigning 777 permission to the folder and config.json.

So, sudo chmod 777 .cf/config.json solved the problem in my case.

Give it a try!

Hooray!

+1
source

By default, CLI cf will attempt to create and write to a directory named .cf in the user's home directory (i.e. ~/.cf ). For some reason, the user on your computer does not have permission to create and / or write to this directory.

You can work around this problem by setting the CF_HOME environment CF_HOME to a different directory in which the user has permissions.

0
source

Unfortunately, no changing permissions for my El Capitan will allow cf to access the config.json file in the .cf folder. I created a new folder in my home space ("CLI") and ensured the correct permissions and set CF_HOME to point to "~ / CLI /". Just creating a new CF_HOME folder and setting CF_HOME in my .bash.profile was not enough. Then I copied the contents of the .cf folder to the new CLI folder. Finally! cf works!

Oh, that is interesting. CF in this version of OSX will be launched only from the home directory, it will not be launched (it will not find config.json) from nothing but root.

0
source

Try the following command: sudo chmod -R 777 /Users/{username}/.cf

This worked for me on OS X El Capitan.

0
source

Config.json should have read and write permissions, in my case the .cf folder has root as the owner and staff as a group, my user on my Yosemite Mac is part of the group staff, but still the config.json file has 600 resolution to fix this problem:

sudo chmod 666 /User/YourUser/.cf/config.json

Also check the permissions of the .cf folder and check if you can read and write. Do something like this: sudo chmod 755 /User/YourUser/.cf

0
source

Delete all .cf folders from your system and try again. This is what @broomyocymru mentioned above. But still, it could help users who are not familiar with shell commands.

0
source

All Articles