mochi93kou
@mochi93kou (まるも)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

<Rails>rails s でエラー

解決したいこと

rails s でサーバーを立ち上げたい。

railsアプリでサーバーを立ち上げようと
rails sをしたところ
エラーが発生してしまいました。

これまでは問題なく立ち上げることができていましたが、
急に立ち上がらなくなってしまいました。

発生している問題・エラー

$ rails s       
=> Booting Puma
=> Rails 6.1.4.7 application starting in development 
=> Run `bin/rails server --help` for more startup options
Rails Error: Unable to access log file. Please ensure that /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
Exiting
/Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:433:in `initialize': Operation not permitted @ rb_sysopen - /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/tmp/pids/server.pid (Errno::EPERM)
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:433:in `open'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:433:in `write_pid'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:317:in `start'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/commands/server/server_command.rb:39:in `start'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/commands/server/server_command.rb:144:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/commands/server/server_command.rb:135:in `perform'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/command/base.rb:69:in `perform'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/command.rb:48:in `invoke'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/commands.rb:18:in `<main>'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/bin/rails:5:in `<top (required)>'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `load'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `call'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
        from /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
        from <internal:/Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/bin/spring:10:in `block in <top (required)>'
        from <internal:kernel>:90:in `tap'
        from /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/bin/spring:7:in `<top (required)>'
        from bin/rails:2:in `load'
        from bin/rails:2:in `<main>'
development.log
Started GET "/" for ::1 at 2022-05-04 11:13:08 +0900
  [1m[35m (1.7ms)[0m  [1m[34mSELECT sqlite_version(*)[0m
Processing by Rails::WelcomeController#index as HTML
  Rendering /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb (Duration: 4.5ms | Allocations: 565)
Completed 200 OK in 17ms (Views: 7.7ms | ActiveRecord: 0.0ms | Allocations: 4270)


Started GET "/" for ::1 at 2022-05-04 11:13:09 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendering /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb (Duration: 12.9ms | Allocations: 267)
Completed 200 OK in 20ms (Views: 17.9ms | ActiveRecord: 0.0ms | Allocations: 1112)


Started GET "/" for ::1 at 2022-05-04 11:13:40 +0900
Processing by Rails::WelcomeController#index as HTML
  Rendering /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /Users/mochizukikouki/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-6.1.4.7/lib/rails/templates/rails/welcome/index.html.erb (Duration: 0.6ms | Allocations: 50)
Completed 200 OK in 5ms (Views: 1.4ms | ActiveRecord: 0.0ms | Allocations: 406)

自分で試したこと

sudo rails sだと問題なくサーバーが立ち上がりました。

bundle updateでも

以下のようなエラーが発生してしまいました。
Operation not permitted @ rb_sysopen -
とあったので権限?かと思い調べてみましたが
解決できませんでした。

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.10
Using minitest 5.15.0
Using zeitwerk 2.5.4
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.6.0
Using bindex 0.8.1
Using msgpack 1.5.1
Using bundler 2.3.7
Using crass 1.0.6
Using public_suffix 4.0.7
Using matrix 0.4.2
Using rack 2.2.3
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using byebug 11.1.3
Using marcel 1.0.2
Using mini_mime 1.1.2
Using regexp_parser 2.3.1
Using childprocess 4.1.0
Using ffi 1.15.5
Using rb-fsevent 0.11.1
Using method_source 1.0.0
Using thor 1.2.1
Using rexml 3.2.5
Using rubyzip 2.3.2
Using tilt 2.0.10
Using nokogiri 1.13.4 (arm64-darwin)
Using addressable 2.8.0
Using sqlite3 1.4.2
Using rack-mini-profiler 2.3.4
Using turbolinks-source 5.2.0
Using sprockets 4.0.3
Using puma 5.6.4
Using websocket-driver 0.7.5
Using rack-test 1.1.0
Using semantic_range 3.0.0
Using sassc 2.4.0
Using selenium-webdriver 4.1.0
Using loofah 2.17.0
Using bootsnap 1.11.1
Using turbolinks 5.2.1
Using rack-proxy 0.7.2
Using rb-inotify 0.10.1
Using i18n 1.10.0
Using rails-html-sanitizer 1.4.2
Using webdrivers 5.0.0
Using tzinfo 2.0.4
Using spring 4.0.0
Using xpath 3.2.0
Using mail 2.7.1
Using capybara 3.36.0
Using listen 3.7.1
Using activesupport 6.1.5.1 (was 6.1.4.7)
Using rails-dom-testing 2.0.3
Using globalid 1.0.0
Using activemodel 6.1.5.1 (was 6.1.4.7)
Using activerecord 6.1.5.1 (was 6.1.4.7)
Using actionview 6.1.5.1 (was 6.1.4.7)
Using activejob 6.1.5.1 (was 6.1.4.7)
Using jbuilder 2.11.5
Using actionpack 6.1.5.1 (was 6.1.4.7)
Using actioncable 6.1.5.1 (was 6.1.4.7)
Using activestorage 6.1.5.1 (was 6.1.4.7)
Using railties 6.1.5.1 (was 6.1.4.7)
Using sprockets-rails 3.4.2
Using actionmailer 6.1.5.1 (was 6.1.4.7)
Using actiontext 6.1.5.1 (was 6.1.4.7)
Using sassc-rails 2.1.2
Using webpacker 5.4.3
Using web-console 4.2.0
Using actionmailbox 6.1.5.1 (was 6.1.4.7)
Using sass-rails 6.0.0
Using rails 6.1.5.1 (was 6.1.4.7)
There was an error accessing
`/Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/Gemfile.lock`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen -
/Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/Gemfile.lock

自分で試したこと

権限を見てみましたが
解決には至らずでした。

$ ls -l                     
total 696
-rw-r--r--    1 mochizukikouki  staff    2210  5  4 11:07 Gemfile
-rw-r--r--    1 mochizukikouki  staff    5673  5  4 11:07 Gemfile.lock
-rw-r--r--    1 mochizukikouki  staff     374  5  4 11:07 README.md
-rw-r--r--    1 mochizukikouki  staff     227  5  4 11:07 Rakefile
drwxr-xr-x@  11 mochizukikouki  staff     352  5  4 11:08 app
-rw-r--r--    1 mochizukikouki  staff    1897  5  4 11:07 babel.config.js
drwxr-xr-x@  10 mochizukikouki  staff     320  5  4 11:08 bin
drwxr-xr-x@  18 mochizukikouki  staff     576  5  4 11:08 config
-rw-r--r--    1 mochizukikouki  staff     160  5  4 11:07 config.ru
drwxr-xr-x@   4 mochizukikouki  staff     128  5  4 11:16 db
drwxr-xr-x@   4 mochizukikouki  staff     128  5  4 11:08 lib
drwxrw-r--@   4 mochizukikouki  staff     128  5  4 11:36 log
drwxr-xr-x@ 708 mochizukikouki  staff   22656  5  4 12:23 node_modules
-rw-r--r--    1 mochizukikouki  staff     366  5  4 11:08 package.json
-rw-r--r--    1 mochizukikouki  staff     224  5  4 11:07 postcss.config.js
drwxr-xr-x@   9 mochizukikouki  staff     288  5  4 11:08 public
drwxr-xr-x@   3 mochizukikouki  staff      96  5  4 11:08 storage
drwxr-xr-x@  12 mochizukikouki  staff     384  5  4 11:08 test
drwxr-xr-x   10 mochizukikouki  staff     320  5  4 11:13 tmp
drwxr-xr-x@   3 mochizukikouki  staff      96  5  4 11:08 vendor
-rw-r--r--    1 mochizukikouki  staff  316728  5  4 11:08 yarn.lock

詳しい方がいればお力をお貸しください。
よろしくお願いします。

0

2Answer

rails s のログの4行目付近に表示されている下記コマンドを実行されましたか?

chmod 0664 /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/log/development.log

0Like

Comments

  1. @mochi93kou

    Questioner

    回答ありがとうございます。
    実行しましたが変化なしでした。

(乱暴ですが)下記でもダメですか?

chmod -R 0777 /Users/mochizukikouki/Documents/homepage/homepage_on_ruby_on_rails/rails-app/homepage2/log

0Like

Comments

  1. @mochi93kou

    Questioner

    実行しましたが同じエラーが出てしまいます。
  2. そうですか
    ご確認ありがとうございました
    識者の回答待ちですね
  3. @mochi93kou

    Questioner

    ご回答ありがとうございました。
    解決することができました。
    原因はPCにインストールされていたウイルス対策のソフトでした。
    ソフトを停止させることで無事サーバーを起動させることができまし。
    ご協力ありがとうございました。
  4. 原因が判明したようで良かったです

Your answer might help someone💌