質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

1回答

7415閲覧

vscodeでvagrant上のrailsアプリがデバッグできない

jkamiya5

総合スコア12

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2017/04/03 06:15

visual studio codeエディタで、railsアプリのデバッグをしたいのですが、なかなか上手くいきません。
railsアプリは、vagrantのubuntu上で実行しているのですが、vagrantを経由する場合としない場合とで、設定方法の違いがあるのでしょうか?


ホスト側
macOS Sierra バージョン10.12.3

ゲスト側
Ubuntu 14.04.5 LTS・・・64bit
ruby 2.4.0
Rails 5.0.2


①Vagrantfileの設定

ruby

1Vagrant.configure(2) do |config| 2 config.vm.provision :shell, path: '.setup/bootstrap.sh' 3 config.vm.synced_folder '.', '/var/www/', owner: 'sample', group: 'sample' 4 5 config.vm.provider 'virtualbox' do |vb| 6 config.vm.box = 'ubuntu/trusty64' 7 config.vm.network :forwarded_port, guest: 3000, host: 3001, auto_correct: true 8 config.vm.network :forwarded_port, guest: 3306, host: 33066, auto_correct: true 9 10 vb.customize ['modifyvm', :id, '--memory', '2048'] 11 end 12end

②launch.jsonの設定

json

1{ 2 "version": "0.2.0", 3 "configurations": [ 4 { 5 "name": "Debug Local File", 6 "type": "Ruby", 7 "request": "launch", 8 "cwd": "${workspaceRoot}", 9 "program": "${workspaceRoot}/main.rb", 10 "useBundler": true 11 }, 12 { 13 "name": "Listen for rdebug-ide", 14 "type": "Ruby", 15 "request": "attach", 16 "cwd": "${workspaceRoot}", 17 "remoteHost": "127.0.0.1", 18 "remotePort": "1234", 19 "remoteWorkspaceRoot": "${workspaceRoot}" 20 }, 21 { 22 "name": "Rails server", 23 "type": "Ruby", 24 "request": "launch", 25 "cwd": "${workspaceRoot}", 26 "program": "${workspaceRoot}/bin/rails", 27 "args": [ 28 "server" 29 ] 30 } 31 ] 32}

③ターミナルで実行するコマンド

$ vagrant up $ vagrant ssh $ sudo su sample $ cd /var/www/app $ bundle exec rdebug-ide --port 1234 --dispatcher-port 26162 script/rails server b '0.0.0.0' Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 127.0.0.1:1234

上記の状態でvscodeからデバッグ(「Listen for rdebug-ide」)を実行すると、vscodeのデバッグコンソールに以下が表示されます

Debugger error: Client: Error: connect ECONNREFUSED 127.0.0.1:1234

どなたか対処法をご教授頂けませんでしょうか。。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

bundle exec rdebug-ide --port 1234 --dispatcher-port 26162 script/rails server b '0.0.0.0'
の コマンドの b にハイフンがついてないように見受けます。
付けて実行してください。

追記(2017/04/04)です。
--port 1234 の 前に、--host 0.0.0.0 をつけてみてください。
b '0.0.0.0' は不要です。

投稿2017/04/03 08:56

編集2017/04/04 01:13
raa0121

総合スコア190

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

jkamiya5

2017/04/03 23:43

raa0121様 ご回答ありがとうございます。 ハイフンをつけて実行したところ、以下のエラーメッセージが出ました。 vscodeで使えるコマンドではないとか、そういうことでしょうか。。 Using ruby-debug-base 0.2.1 Usage: rdebug-ide is supposed to be called from RDT, NetBeans, RubyMine, or the IntelliJ IDEA Ruby plugin. The command line interface to ruby-debug is rdebug. Options: -h, --host HOST Host name used for remote debugging -p, --port PORT Port used for remote debugging --dispatcher-port PORT Port used for multi-process debugging dispatcher --evaluation-timeout TIMEOUT evaluation timeout in seconds (default: 10) --stop stop when the script is loaded -x, --trace turn on line tracing -l, --load-mode load mode (experimental) -d, --debug Debug self - prints information for debugging ruby-debug itself --xml-debug Debug self - sends information <message>s for debugging ruby-debug itself -I, --include PATH Add PATH to $LOAD_PATH --keep-frame-binding Keep frame bindings --disable-int-handler Disables interrupt signal handler --rubymine-protocol-extensions Enable all RubyMine-specific incompatible protocol extensions --catchpoint-deleted-event Enable chatchpointDeleted event --value-as-nested-element Allow to pass variable's value as nested element instead of attribute Common options: -v, --version Show version invalid option: -b
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問