Cannot create directory permission denied - ruby-on-rails

I am deploying my rails application to a vps. On cap deploy:setup I get the error that mkdir: cannot create directory `/apps'.
I am using set :user_sudo, false in my deploy.rb file.
I am a linux newbie, How can I give permission to the current user to create directories.

You will not have (or should not) hand permission to create directories to the root ('/') directory.
Change the mkdir command to create the directory in a directory where the process has the appropriate permissions.

Related

Access to the path 'C:\inetpub\wwwroot\App_Data\TEMP\PluginCache' is denied. Amazon AWS Beanstalk

I'm trying to setup an Umbraco website on Amazon AWS Beanstalk using the AWS Toolkit for Visual studio 2017, I have added the .ebextensions folder and inside my config file
{
"containercommands": {
"01-changeperm": {
"command": "icacls \"C:/inetpub/wwwroot/App_Data\" /grant IIS_IUSRS:(OI)(CI)"
}
}
}
I have also tried DefaultAppPool instead of IIS_IUSRS as per this post How can I set folder permissions for elastic beanstalk windows application? and I have also tried
commands:
create_default_website_folder:
command: if not exist "C:\inetpub\wwwroot" mkdir "C:\inetpub\wwwroot"
update_iis_user_permissions:
command: Icacls.exe "C:\inetpub\wwwroot" /grant IIS_IUSRS:(OI)(CI)F
from this post https://aws.amazon.com/blogs/devops/run-umbraco-cms-with-flexible-load-balancing-on-aws/ along with many other post, but none work, does anyone know what else I need to do as I'm constantly getting the following error.
Access to the path 'C:\inetpub\wwwroot\App_Data\TEMP\PluginCache' is
denied.
You can visit this page to see what Umbraco needs: https://our.umbraco.com/documentation/Getting-Started/Setup/Server-Setup/permissions
Essentially all of these need modify permissions to all of the folders in your umbraco installation:
IUSR
IIS_IUSRS
IIS apppool\[appoolname]
Wow! your post is really help me (and https://thedeveloperspace.com/granting-write-access-to-asp-net-apps-hosted-on-aws-beanstalk/ and ASP.Net Core at AWS EBS - write permissions and .ebextensions )
In my scenario my local folder for temp files is at
C:\inetpub\wwwroot\Temp
So I reedit your command to
commands:
create_default_website_folder:
command: if not exist "C:\inetpub\wwwroot\Temp" mkdir "C:\inetpub\wwwroot\Temp"
container_commands:
01storage_permissions:
command: "icacls C:\\inetpub\\wwwroot\\Temp /grant DefaultAppPool:(OI)(CI)F"
Then I have permission to use my target folder thanks for the mkdir command.
Becuase your Access to the path 'C:\inetpub\wwwroot\App_Data\TEMP\PluginCache' is denied.
May be your config must be specific folder like this ?
commands:
create_default_website_folder:
command: if not exist "C:\inetpub\wwwroot\App_Data\TEMP\PluginCache" mkdir "C:\inetpub\wwwroot\App_Data\TEMP\PluginCache"
update_iis_user_permissions:
command: Icacls.exe "C:\inetpub\wwwroot\App_Data\TEMP\PluginCache" /grant IIS_IUSRS:(OI)(CI)F

Capistrano configuration leading to mkdir permission denied

Upon execution a deploy to a server for a specific application, the process interrupts at this stage
DEBUG [88db4789] Command: ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.3.4" ; /usr/bin/env mkdir -p /var/www/v4/shared /var/www/v4/releases )
DEBUG [88db4789] mkdir:
DEBUG [88db4789] cannot create directory ‘/var/www’
DEBUG [88db4789] : Permission denied
Note: this occurring only for this particular application. Another application that deploys to the same server processes past this stage
I have attempted to change ownership as suggested here, but that fails
chown: cannot access ‘/var/www/’: No such file or directory
so I am led to believe a configuration issue is the culprit. Aside from the environment data
server 'xx.xxx.xxx.xxx', user: 'deploy', roles: %w{db web app}
where have I missed something?
Your server instance does not have the folder /var/www, so you can do manually by ssh to that server as user deploy then try to make the folder yourself.
I think it again will fail because of your deploy user does not have the rights to /var folder. Try to change the ownership following the guide you have to do so.
While yeuem1vannam's answer is valid, this use case actually had a different problem in the deploy.rb file. The path specified there had an error in the user name, thus the permission error to create the folder upon deploy.

Bitnami Permissions php.ini

I am trying the modify a php.ini file in a bitnami moodle deployment, as user 'bitnami' but for some reason my permissions are denied through sftp.
I have never used the console before, so can someone please provide some step by step instructions to modify these files or permissions.
When you launched a Bitnami Moodle Cloud Image, the permissions set by default for the file /opt/bitnami/php/etc/php.ini are 0644 with user: bitnami group: root. Therefore, if you are connecting via SSH to your server using the user 'bitnami' you must be able to edit the file.
On the other hand, the permissions set by default to the folder /opt/bitnami/php/etc/ are 0755 with user: root group: root. Therefore, to create a new file on that folder you must have root permissions. That's the reason why you can't upload a new file via SFTP to that folder with user 'bitnami'.
More information at:
https://docs.bitnami.com/general/faq/#how-to-connect-to-the-server-through-ssh
https://docs.bitnami.com/general/faq/#how-to-upload-files-to-the-server-with-sftp

Permission denied in tmp

I just deployed a Rails 3 app with Ruby 1.9.2. I have been getting several errors.
application.css wasn't compiled. so I set pre compilation in production.rb to false;
Then I got: cannot generate tempfile, so I did rake tmp:clear;
And now I get ActionView::Template::Error (Permission denied - /srv/www/appname/tmp/cache/assets): and I haven't been able to fix this one.
Please help.
If the user:group running your web server is http:http and it's running on *nix, do this:
sudo chown -R http:http /srv/www/appname/
Also, silly question, but does /tmp/cache/assets exist?
And, if so, as #leonel points out, you may also need to change the permissions:
chmod 777 /srv/www/appname/tmp/cache
Be careful setting 777 permissions on anything. Only do this to verify a permissions issue, then reset to the most minimal permissions necessary.
Most likely you're running your app under apache passenger.
You have to change the owner of config/environment.rb to somebody who has permissions to your app's folder.
chown -R www-data:www-data /path/to/app
Make the tmp folder of your project writable:
chown -R group:user /path/to/rails/app/tmp
chmod -R 777 /path/to/rails/app/tmp
In your console, run rake tmp:cache:clear
Restart your application.
You probably didn't create your Rails application with the user running the server now. Can you paste the output of ls -alh /srv/www/appname/tmp/cache/assets and tell us the user running the webserver ?
Now for those of us that are using windows
- If you are an administrator and see this error
ActionView::Template::Error (Permission denied # utime_failed) C:/User/..../tmp/cache/assets/sprochets/v3.0/E5/E5PZx-mq8.cache
Then it is Permission and Ownership setting issue on Windows.
You can go to the tmp folder on your application and give yourself(User) permission to **Read, Write and Execute ** on the folder.
Click [here][1] to view how to give permissions.
Quick Fix. Open your terminal and run the following command as an administrator
takeown /f <location of your app tmp folder> /r /d y
Then Restart your server.
I encountered this error recently. Apache was not able to write to tmp directory
cannot generate tempfile
/tmp/RackRewindableInput2xxxxxxxxxxxxxxxxx'
/app-lib/lib/ruby/1.8/tempfile.rb:52:ininitialize'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:in new'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:inmake_rewindable'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:26:in read'
app-dir/vendor/gems/rack-1.0.1/lib/rack/request.rb:134:inPOST'
I checked permission of tmp directory and it had permission to all groups to write to it.
I changed owner of tmp directory and it didn't resolve the error either.
The culprit was tmp directory was filled with too many large files, and looks like somehow apache didn't had enough space to write this new file.
Cleared all temp and old files. It sorted out the issue.
We need to grant permissions to access the required directory for the system root user
sudo chmod 777 -R your_project_directory_to_be_access
In your case you can use:
sudo chmod 777 -R /srv/www/appname/tmp/
For security reasons, just keep in your mind:
chmod 777 gives everybody read, write and execute rights which for most problems is definitively too much.
I think a better solution without giving everyone manage rights to tmp folder is like that:
sudo rake tmp:cache:clear
This will clear the temp folder and when you run rails server again it won't give error.
In my localhost it gave this error, and the command chmod 777 C:/Sites/project_name/tmp/cache/ solved my problem.
Most probably you gave permission to your app's main folder read and execute mode. However, in order to generate new files from your app, you also need to give write permission for required folder. For example: yUML uses tmp folder for generating files. I gave tmp folder write permission:
chmod -R 777 /usr/share/nginx/html/yuml_product/tmp
solved my problem.

Capistrano: Problem with permissions on deploy

I have a problem deploying a Rails app to my server. Performing a
cap deploy
I get lots of errors, stating that chmod is not able to change permissions of (and only of) git object files:
...
** [out :: ██████████████] chmod: changing permissions of `/srv/www/kunsthof/releases/20101113162736/.git/objects/04/779c6d894bbea4c26d6e035f71cd1ab124cc90': Operation not permitted
...
failed: "sh -c 'chmod -R g+w /srv/www/kunsthof/releases/20101113162736'" on ██████████████
The files are put there on the deploy itself, so it should be possible for the deploy user to change their permissions. Any suggestions on what could be the problem here?
Usually on deploy if you are using cached-copy, your repo will be cloned to a shared directory and will be rsynced/copied to the current release directory. While coping, you should be excluding .git directory and other unnecessary directories like spec / test (which are not going to used in production) with the following variable:
set :copy_exclude, [".git", "spec"]
With this, you are not going to copy the .git directory and should not be facing the permission problem on doing chmod there after.

Resources