Ruby on railsのDockerコンテナ作成時にエラー「Device or resource busy @ rb_sysopen – /myapp/Gemfile (Errno::EBUSY)」が出た場合の対処

Docker Ruby on rails ツール フレームワーク

下記のサイトに従ってセットアップをしたところ、

クイックスタート・ガイド:Docker Compose と Rails — Docker-docs-ja 17.06.Beta ドキュメント

Device or resource busy @ rb_sysopen – /myapp/Gemfile (Errno::EBUSY)

というエラーが出てしまった。

rubyとrailsのバージョンは最新してあります。

以下エラーの内容。

>docker-compose run web rails new . --force --database=postgresql --skip-bundle
Starting docker_db_1 ... done
       exist
   identical  README.md
   identical  Rakefile
   identical  .ruby-version
   identical  config.ru
   identical  .gitignore
       force  Gemfile
Traceback (most recent call last):
        33: from /usr/local/bundle/bin/rails:23:in `<main>'
        32: from /usr/local/bundle/bin/rails:23:in `load'
        31: from /usr/local/bundle/gems/railties-5.2.1/exe/rails:10:in `<top (required)>'
        30: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        29: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        28: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/cli.rb:18:in `<top (required)>'
        27: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
        26: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
        25: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        24: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        23: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        22: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/commands/application/application_command.rb:26:in `perform'
        21: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        20: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
        19: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
        18: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
        17: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
        16: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'
        15: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        14: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        13: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/generators/rails/app/app_generator.rb:295:in `create_root_files'
        12: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/generators/app_base.rb:159:in `build'
        11: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/generators/rails/app/app_generator.rb:59:in `gemfile'
        10: from /usr/local/bundle/gems/railties-5.2.1/lib/rails/generators/rails/app/app_generator.rb:19:in `template'
         9: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/file_manipulation.rb:122:in `template'
         8: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:25:in `create_file'
         7: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions.rb:94:in `action'
         6: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:60:in `invoke!'
         5: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/empty_directory.rb:115:in `invoke_with_conflict_check'
         4: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:77:in `on_conflict_behavior'
         3: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:88:in `force_or_skip_or_conflict'
         2: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `block in invoke!'
         1: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `open'
/usr/local/bundle/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `initialize': Device or resource busy @ rb_sysopen - /myapp/Gemfile (Errno::EBUSY)

原因は…

Gemfileをテキストエディタで開きっぱなしにしていたためでした。

ファイルを閉じて再度docker runしたら成功。

Gemfileに書き込めるようにしておかないといけないんですね。

はずかしい。

 

コメント/ピンバック

タイトルとURLをコピーしました