By johnyeung628
I have built a rails app on my local machine and would like to deploy it, following the tutorial here: https://www.digitalocean.com/community/tutorials/how-to-launch-your-ruby-on-rails-app-with-the-digitalocean-one-click-image
However, after uploading the whole app through SFTP, creating a postgresql user named ‘postgres’ (I did this to get around the peer authentication error), running the command
RAILS_ENV=production rake db:migrate as the UNIX user postgres gave me the following errors:
Rails Error: Unable to access log file. Please ensure that /home/rails/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. rake aborted! Errno::EACCES: Permission denied - /home/rails/db/schema.rb
I have spent quite a bit of time googling around but no luck. Please help.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The issue you’re seeing is due to the fact that you are running the command as the user postgres who doesn’t have permissions to access /home/rails/db/schema.rb Instead of running rake as the UNIX user postgres, create a postgres user/password for your Rails app:
sudo -u postgres psql
create role myapp_user with createdb login password 'db_password';
Then in your database.yml file:
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp_user
password: db_password
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp_user
password: db_password
production:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp_user
password: db_password
@asb I am having the same issue even after following this solution. it still says:
deploy@TTP:/srv/ttp$ rake db:migrate
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /srv/ttp/db/schema.rb
/usr/local/rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:236:in `initialize'
/usr/local/rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:236:in `open'
/usr/local/rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:236:in `block (3 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:50:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.2/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:schema:dump
(See full trace by running task with --trace)
Can you help me on this.
You need to change app folder files permission as:
sudo chown -R jsingh /var/www/
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.