概要
Ruby on Railsをインストールする際に下記のようなエラーが発生しインストールが出来ませんでした。
gem install rails実行時のエラー内容
console
> gem install rails
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210504-17032-oj9pk4.rb extconf.rb
creating Makefile
current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make DESTDIR\= clean
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/make-0.3.1/bin/make:4:in `<top (required)>': undefined local variable or method `make' for main:Object (NameError)
from C:/Ruby30-x64/bin/make:23:in `load'
from C:/Ruby30-x64/bin/make:23:in `<main>'
current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make DESTDIR\=
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/make-0.3.1/bin/make:4:in `<top (required)>': undefined local variable or method `make' for main:Object (NameError)
from C:/Ruby30-x64/bin/make:23:in `load'
from C:/Ruby30-x64/bin/make:23:in `<main>'
make failed, exit code 1
対処方法
結論から言うと、"gem uninstall make" を実行してmakeをアンインストールすれば解決しました。
VSCodeの拡張機能でRuby on Railsをインストールしていたことが原因かもしれません。
makeをアンインストール後に、再度Railsのインストールを実行したところ、無事インストールが完了しました。
console
> gem uninstall make
Remove executables:
make
in addition to the gem? [Yn] y
Removing make
Successfully uninstalled make-0.3.1
> gem install rails
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.3
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.7
Successfully installed actioncable-6.1.3.1
Successfully installed rails-6.1.3.1
Parsing documentation for websocket-driver-0.7.3
Installing ri documentation for websocket-driver-0.7.3
Parsing documentation for nio4r-2.5.7
Installing ri documentation for nio4r-2.5.7
Parsing documentation for actioncable-6.1.3.1
Installing ri documentation for actioncable-6.1.3.1
Parsing documentation for rails-6.1.3.1
Installing ri documentation for rails-6.1.3.1
Done installing documentation for websocket-driver, nio4r, actioncable, rails after 1 seconds
4 gems installed
参考URL