I'm very new to Ruby on Rails. I created a model by running the rails g scaffold command, and then tried to run rails db:migrate in the wsl terminal which gave me this huge error:
rails db:migrate
/home/nidhi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.4.1/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Rails Error: Unable to access log file. Please ensure that /mnt/c/Windows/system32/railsfriends/friends/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /mnt/c/Windows/system32/railsfriends/friends/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
(0.6ms) SELECT sqlite_version(*)
(0.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
rails aborted!
ActiveRecord::StatementInvalid: SQLite3::ReadOnlyException: attempt to write a readonly database
/mnt/c/Windows/system32/railsfriends/friends/bin/rails:5:in `<top (required)>'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:10:in `block in <top (required)>'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:7:in `tap'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:7:in `<top (required)>'
Caused by:
SQLite3::ReadOnlyException: attempt to write a readonly database
/mnt/c/Windows/system32/railsfriends/friends/bin/rails:5:in `<top (required)>'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:10:in `block in <top (required)>'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:7:in `tap'
/mnt/c/Windows/system32/railsfriends/friends/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I tried unchecking the "Read only" property of the development.log file it mentions, but that did not help. How can I solve this error?
CodePudding user response:
Restarting my computer worked for me! I just had to go to my original folder and uncheck the "Read only" property, then restart the computer. The rails db:migrate
command works now.