【Docker, React, Rails】uninitialized constant Gem::Source (NameError)について
エラー内容
- こちらの【備忘録】【環境構築】Docker + Ruby on Rails + ReactでSPA化の記事を参考に環境構築
$ docker-compose run backend rails new . --force --no-deps --database=postgresql --api
を入力したタイミングで、以下のエラーが発生- エラー内容
- uninitialized constant Gem::Source (NameError)
- (defined?(@source) && @source) || Gem::Source::Installed.new
対応内容
解決策
$ docker-compose run backend rails new . --force --no-deps --database=postgresql --api
のコマンドを入力- エラーで落ちるが、そのままdocker-compose bulid
- bundler周りの不具合ではなく、シンプルにbundle installされていないため、落ちてしまっていた。
- そのままcreate-react-appのコマンドを実行→環境構築成功
エラーログ
コード
エラーログ
[shinjiasai@ShinjinoMacBook-Pro:~/Project/delivery_order]
$ docker-compose run backend rails new . --force --no-deps --database=postgresql --api
WARN[0000] Found orphan containers ([delivery_order_web_run_ef3563137a6d delivery_order_web_run_8f8d1cac90b2]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[+] Running 1/0
⠿ Container delivery_order-db-1 Running 0.0s
exist
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
force Gemfile
run git init from "."
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m
Initialized empty Git repository in /myapp/.git/
create app
create app/assets/config/manifest.js
...中略...
remove config/initializers/new_framework_defaults_7_0.rb
run bundle install
[12, #, #, ["/usr/local/lib/ruby/3.1.0/bundler/rubygems_ext.rb:18:in `source'", "/usr/local/lib/ruby/3.1.0/bundler/rubygems_ext.rb:50:in `extension_dir'",
...中略...
"/usr/local/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'", "/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in'",
"/usr/local/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'", "/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in ` /usr/local/lib/ruby/3.1.0/bundler/rubygems_ext.rb:18:in `source': uninitialized constant Gem::Source (NameError) (defined?(@source) && @source) || Gem::Source::Installed.new ^^^^^^^^ Did you mean? Gem::SourceList from /usr/local/lib/ruby/3.1.0/bundler/rubygems_ext.rb:50:in `extension_dir' from ...省略...