Rails Error: Unable to access log file on aws lambda - ruby-on-rails

I'm trying to run the Rails app in AWS lambda (using lamby gem) via docker image.
I'm getting the following error.
Rails Error: Unable to access log file. Please ensure that /fi-service/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /fi-service/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I even added the following commands in the dockerfile (as suggested here)
RUN touch log/development.log
RUN chmod 0664 log/development.log

Related

Getting "No such file or directory/" error while running command in docker

I am trying to load the database as part of the image creation using dockerfile. At the end, I am trying to load the data to the mysql database by adding a shell file as part of the docker entry point.
COPY ./scripts/initdb.sh /docker-entrypoint-initdb.d/
the initdb.sh has the following content
mysql -u root -p<root_password> <database_name> < /data/dump.sql
The problem is when the file is executed I am getting the following error:
: No such file or directory/initdb.sh: line 1: /data/dump.sql
I have checked the following
the files exists in the correct directory
the permission are proper (-rwxr-xr-x)
changed the permission thru RUN chmod +x /docker-entrypoint-initdb.d/*.sh
but, nothing seems to be working, am sure there is a something simple I am missing.

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.

My Rails apps all suddenly became read-only

I was working on my rails app, left it for a while, came back, and tried to restart my server. In response, I got back this error:
Rails Error: Unable to access log file. Please ensure that /home/user/app/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I have no idea what I could have done to cause this. I never even touched my log directory. I tried to run chmod 0666 /home/user/app/log/development.log and then various other chmod commands, like chmod 0664 and chmod 777. Each time I got back:
chmod: changing permissions of ‘/home/user/app/log/development.log’: Read-only file system
but I always got back the same error from rails s.
Then I gave up and switched to a different app I'm working on, but after running rails s for that app, I got back basically the same error:
Rails Error: Unable to access log file. Please ensure that /home/user/sweat/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
What is going on? I'm using Ubuntu 14.04.
UPDATE
Running sudo chmod 777 -R log gives me back this:
sudo: unable to open /var/lib/sudo/user/1: No such file or directory
chmod: changing permissions of ‘log’: Read-only file system
chmod: changing permissions of ‘log/development.log’: Read-only file system
chmod: changing permissions of ‘log/.keep’: Read-only file system
if you are using Linux!
try this => cd home/user/app
then => sudo chmod 777 -R log
I hope this helps you!

Rails Error: Unable to access log file And ActionView::Template::Error Permission denied

I'm deploy my app with capistrano on centos (apache + passenger), when access my web I got `HTTP 500 (Internal Server Error)' and check error_log file , here's error look likes :
DAV/2 Phusion_Passenger/3.0.19 mod_ssl/2.2.24 OpenSSL/1.0.0-fips configured -- resuming normal operations
Rails Error: Unable to access log file. Please ensure that /home/admin/myaap/releases/20130506191509/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed..
production.log permission
-rwxrwxr-x 1 root root 46211 May 6 20:49 production.log
and
ActionView::Template::Error (Permission denied - /home/admin/myaap/releases/20130506191509/tmp/cache/assets/D3B
directory D3B not found.
I am looking for a solution via google, one of which is sudo chown -R root:root /home/admin/myapp/ but not working for me, Is there any other way to fix it?
Note :
I'm using user root for deploy and installing rvm, and directory root location on user 'admin' (kloxo control panel)
UPDATE
On error_log file not found error about permission and unable to access, I'm using chmod go-w /home/admin/myapp and chmod 0666 production.log , but my web still 500 server error, How do I check error?
As Rails is suggesting in the error log, you should change permissions for the log file to 066:
chmod 0666 production.log
You are using root to deploy, but the web server is using another user name.
You need to make your apache user the owner of your app like:
sudo chown -R apacheuser:apacheuser /home/admin/myapp/
I've always had success with the the log file permissions as 644. When this has happened to me, more than once I might add, it has always been answered by the question linked below. Since this is the first answer in Google for the query I use, I'm linking to the answer that I really want.
Rails: Unable to access log file

Running system call in rails causes error

When I try to run the following code:
system("pdftk #{##temp_file_path} output #{##file_path} user_pw #{##pass}")
I get this error:
Permission denied - /tmp/billing.pdf
I tried running:
chmod +x /tmp
But that didn't help.
Any suggestions?
What are the permissions on /tmp (you can find this with 'ls -ld /tmp')? Are you trying to create billing.pdf or modify an existing file?
The user executing your rails process probably needs write privilege in addition to execute privilege (which you were adding with the 'chmod +x' command). Also, if there's already a billing.pdf file in /tmp, it would need to allow the rails user to read or write it (whatever you're trying to do).
Adding this system call first fixed the problem:
system("chmod +w ##temp_file_path")
For some reason rails pdf-writer plugin generates files as read only.
Maybe it has options to override that. :)

Resources