[Ruby] What to do when the error "cannot load such file" appears when executing VS Code debug

Cause

The cause was that $ {file} was replaced with the full path. It was OK if you wrote `" $ {file} "` instead of "$ {workspaceRoot}/$ {file}" `` `. Thank you for pointing out @ nodai2h_ITC. : bow :: bow :: bow ::

Execution environment

macOS (version: 11.1) VSCode (version: 1.51.1) Ruby (version: 2.7.2)

approach

Change the specification of program in launch.json to " $ {file} "``` instead of "` "$ {workspaceRoot}/$ {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
        }
    ]
}

error contents

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>'

Recommended Posts

[Ruby] What to do when the error "cannot load such file" appears when executing VS Code debug
[Ruby / Rails] What to do when NoMethodError appears when using a destructive method such as filter!
[Rails / Maybe it can be applied to other things? ] What to do if failure / error __send__ (method file) rspec cannnot road such file appears when executing RSpec
What to do about the "cannot be read or is not a valid ZIP file" error
[Error] `cannot load such file --mime/types/data (LoadError)`
What to do when Blocked Host: "host name" appears in Ruby on Rails
When you get LoadError (cannot load such file --ruby_file) when you require in Ruby
[Grails] Error occurred running What to do when the Grails CLI does not start
[Ubuntu] What to do when MongoDB cannot be started due to a SocketException error
[React.useRef] What to do when the latest state cannot be referenced in the event listener
What to do if the debug gem installation fails
What to do if error while creating mount source path'/ host_mnt / Users / ~': mkdir / host_mnt / Users / ~: file exists when the container starts
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
What to do when "Fail to load the JNI shared library" is displayed in Eclipse
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do when Cannot apply expression operators to method binding
What to do if the adb command cannot be executed
[Programming beginner] What to do when rails s becomes an error in the local development environment
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What to do when the changes in the Servlet are not reflected
I tried to translate the error message when executing Eclipse (Java)
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
Automatic file upload with old Ruby gem What to do with Watir
What to do if an error occurs in VS Code when importing a django module or your own module installed by pip install
What to do when javax.batch.operations.JobStartException occurs
I ran the rails server command on windows10, Ruby2.6.6 and got "cannot load such file --sqlite3 / sqlite3_native"
What to do when the error "Non-static variable x cannot be referenced from static context" in Java. Lessons from the very first step in programming Remarks 01
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina
[IOS] What to do when the image is filled with one color
What to do when CentOS cannot be started with VirtualBox on Catalina
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
What to do if you don't like the code generated by swagger-codegen-cli
What to do if you get an error when you hit Heroku logs
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
What to do if the build fails with the error "Module compiled with Swift x.x.x cannot be imported by the Swift x.x.x compiler"
What to do if you get an "A server is already running." Error when you try to start the rails server
How to translate the error message into Japanese (What to do if you cannot log in for some reason)
What to do when undefined method ʻuser_signed_in?'
What to do when you want to delete a migration file that is "NO FILE"
What to do if you get the error message unrecognized selector send to instance "***"
What to do if the changes are not reflected in the jar manifest file
What to do when the value becomes null in the second getSubmittedValue () in JSF Validator
What to do when rails db: seed does not reflect in the database
[Ruby] Meaning of &. How to avoid the error when the receiver (object) is nil
When I try to run docker-compose, I get the error "Cannot locate specified Dockerfile: Dockerfile"
What to do when "Nil location provided. Can't build URI." Appears on CarrierWave
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied