-1
cameronnc@cameron-20fms3pk00]─[~/Desktop/snetwork]
└──╼ $bundle exec rails db:create
Rails Error: Unable to access log file. Please ensure that /home/cameronnc/Desktop/snetwork/log/development.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /home/cameronnc/Desktop/snetwork/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rails aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /home/cameronnc/Desktop/snetwork/config/master.key
/home/cameronnc/Desktop/snetwork/config/environment.rb:5:in `<main>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)

I am trying to create my db in rails and want to use the latest version of Ruby and rails but I get many many permission errors. I wasn't even allowed to modify my gem files unless I signed in as root. How can I fix this error?

So I ran the following commands BUT I still get an error message of some kind:

[✗]─[cameronnc@cameron-20fms3pk00]─[~/Desktop/snetwork]
└──╼ $rails db:create
Rails Error: Unable to access log file. Please ensure that /home/cameronnc/Desktop/snetwork/log/development.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /home/cameronnc/Desktop/snetwork/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
FATAL:  role "cameronnc" does not exist
Couldn't create 'snetwork_development' database. Please check your configuration.
rails aborted!
ActiveRecord::ConnectionNotEstablished: FATAL:  role "cameronnc" does not exist


Caused by:
PG::ConnectionBad: FATAL:  role "cameronnc" does not exist

Tasks: TOP => db:create
(See full trace by running task with --trace)
┌─[✗]─[cameronnc@cameron-20fms3pk00]─[~/Desktop/snetwork]
└──╼ $sudo su
┌─[root@cameron-20fms3pk00]─[/home/cameronnc/Desktop/snetwork]
└──╼ #sudo -u postgres createuser --superuser cameronnc
┌─[root@cameron-20fms3pk00]─[/home/cameronnc/Desktop/snetwork]
└──╼ #exit
exit
┌─[cameronnc@cameron-20fms3pk00]─[~/Desktop/snetwork]
└──╼ $bundle exec rails db:create
Rails Error: Unable to access log file. Please ensure that /home/cameronnc/Desktop/snetwork/log/development.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /home/cameronnc/Desktop/snetwork/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
   (866.0ms)  CREATE DATABASE "snetwork_development" ENCODING = 'unicode'
Created database 'snetwork_development'
   (684.0ms)  CREATE DATABASE "snetwork_test" ENCODING = 'unicode'
Created database 'snetwork_test'

Why am I receiving a:

$bundle exec rails db:create Rails Error: Unable to access log file. Please ensure that /home/cameronnc/Desktop/snetwork/log/development.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /home/cameronnc/Desktop/snetwork/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

What is going on and how can I address such an odd error?

Alter Lagos
  • 12,090
  • 1
  • 70
  • 92
naarter
  • 21
  • 5
  • You need to create a user in your postgresql database that matches your login. https://ubiq.co/database-blog/create-user-postgresql/ – Jad Apr 29 '22 at 21:56
  • https://stackoverflow.com/a/71996907/12817385 before posting make sure to search stack overflow first – Ben Garcia Apr 29 '22 at 22:27

1 Answers1

1

I see two errors:

Error 1: File permissions

Rails Error: Unable to access log file. Please ensure that /home/cameronnc/Desktop/snetwork/log/development.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /home/cameronnc/Desktop/snetwork/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

You can try to fix the permissions with chown and chmod. If you're not familiar with these tools, this is a good opportunity to learn.

If you don't have time to learn to use chown and chmod, you can delete your application (~/Desktop/snetwork) and start again running rails new as yourself.

Error 2: Invalid database configuration

FATAL: role "cameronnc" does not exist Couldn't create 'snetwork_development' database. Please check your configuration. rails aborted! ActiveRecord::ConnectionNotEstablished: FATAL: role "cameronnc" does not exist

You can either fix your database configuration (config/database.yml) by specifying a valid username, or you can create a cameronnc user. Read the postgres manual for details on user mgmt.

Jared Beck
  • 16,796
  • 9
  • 72
  • 97