3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Ruby] VSCodeのdebug実行でエラー「cannot load such file」が出た際の対処

Last updated at Posted at 2021-01-15

###原因
${file}はフルパスに置き換えられることが原因でした。"${workspaceRoot}/${file}"ではなく"${file}"と記載すればOKでした。
@nodai2h_ITC さん、ご指摘ありがとうございました。:bow::bow::bow:

###実行環境
macOS (version: 11.1)
VSCode (version: 1.51.1)
Ruby (version: 2.7.2)

###対処法
launch.json内のprogramの指定を、"${workspaceRoot}/${file}"ではなく"${file}"に変更すればOK

launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Local File",
            "type": "Ruby",
            "request": "launch",
            //"program": "${workspaceRoot}/${file}",
            "program": "${file}",
            "useBundler": true
        }
    ]
}

###エラー内容

Uncaught exception: cannot load such file -- /Users/kzyonzw/works/ruby/Users/kzyonzw/works/ruby/main.rb
	/Users/kzyonzw/.rbenv/versions/2.7.2/bin/rdebug-ide:23:in `load'
	/Users/kzyonzw/.rbenv/versions/2.7.2/bin/rdebug-ide:23:in `<top (required)>'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `load'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:28:in `run'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:494:in `exec'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:30:in `dispatch'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:24:in `start'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:49:in `block in <top (required)>'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:37:in `<top (required)>'
	/Users/kzyonzw/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
	/Users/kzyonzw/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
bundler: failed to load command: rdebug-ide (/Users/kzyonzw/.rbenv/versions/2.7.2/bin/rdebug-ide)
/Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_load': cannot load such file -- /Users/kzyonzw/works/ruby/Users/kzyonzw/works/ruby/main.rb (LoadError)
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_program'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.7.2/bin/rdebug-ide:193:in `<top (required)>'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/bin/rdebug-ide:23:in `load'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/bin/rdebug-ide:23:in `<top (required)>'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `load'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli/exec.rb:28:in `run'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:494:in `exec'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:30:in `dispatch'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/cli.rb:24:in `start'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:49:in `block in <top (required)>'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.5/exe/bundle:37:in `<top (required)>'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
	from /Users/kzyonzw/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
3
1
2

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?