LoginSignup
0
0

RubyMine2023.2.xでDockerコンテナ内のコードをデバッグ実行が動かない問題とその解決法

Posted at

Dockerコンテナで動いているRailsベースのバックエンドサービスのデバッグをしようとしたところ、debaseとruby-debug-ideがインストールされてないということで、RubyMineがこの2つのgemをインストールしようとしたものの、コケてしまう現象に遭遇しました。

エラーメッセージに下記のような内容が出力されているので

Successfully installed debase-ruby_core_source-3.2.1
Building native extensions. This could take a while...
ERROR:  Error installing ./debase-3.0.0.beta.7.gem:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/debase-3.0.0.beta.7/exto
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.2.0 extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
**************************************************************************
No source for ruby-3.2.1-p31 (revision 31819e82c88c6f8ecfaeb162519bfa26a14b21fd) provided with
debase-ruby_core_source gem. Falling back to ruby-3.2.0-p0.
**************************************************************************
checking for vm_core.h... yes
checking for iseq.h... yes
checking for method.h... yes
checking for version.h... yes
creating Makefile
/usr/local/bundle/gems/debase-3.0.0.beta.7/exto/extconf_common.rb:75:in ``': No such file or directory - g++ (Errno::ENOENT)
	from /usr/local/bundle/gems/debase-3.0.0.beta.7/exto/extconf_common.rb:75:in `build_makefile'
	from extconf.rb:2:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/debase-3.0.0.beta.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/debase-3.0.0.beta.7 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/debase-3.0.0.beta.7/gem_make.out

エラーをよく読んでみると

No such file or directory - g++ (Errno::ENOENT)

そうか、コンパイラがなくてネイティブコードがビルドできなかったのか。。。

Dockerファイルに

RUN apk add alpine-sdk # alpineベースの場合
RUN apt install build-essential # debianベースの場合

を追記してdockerイメージを作成しなおした後で、RubyMineでデバッグするとdebase-3.0.0.beta.7.gemとruby-debug-ide-3.0.0.beta.12.1.gemのインストールが成功し、デバッグもできるようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0