Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Can't launch rails app #62

Closed
germangrasso opened this issue Sep 19, 2016 · 16 comments
Closed

Can't launch rails app #62

germangrasso opened this issue Sep 19, 2016 · 16 comments

Comments

@germangrasso
Copy link

  • vscode-ruby version: 0.6.0
  • Ruby version: 2.3.1 (using RVM)
  • VS Code version: 1.5.2
  • Operating System: RHEL7

I'm trying to run my rails app from VScode using the extension but I just can't.
I have this in my lauch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Rails server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "/home/AMER/ggrasso/src/unisporkal/account",
            "program": "/home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails",
            "args": [
                "server"
            ]
        }
]}

Expected behavior

Rails server starts and I can browse my app.

Actual behavior

I'm only seeing the status bar blink in red once and this message in the Output console: "waiting for debug protocol on stdin/stdout"
Nothing else happens.
The program path seems to be correct because if I change it then there is an error in the debugger console because it can't find rails.

Is there a log that I can look at to see what's the underlying error?

Thanks,
German

@HookyQR
Copy link
Contributor

HookyQR commented Sep 19, 2016

Hi @germangrasso, it seems like the debug server isn't starting up correctly. Do you have ruby-debug-ide installed? If so, are you running VS Code from a shortcut icon or from the command line. If you're running from an icon, you may be getting the default ruby version of the system rather than the one rvm is setup to use for your project directory.

The only place errors would show up is in the console. You can open that from Help->Toggle Developer Tools in VS code.

@germangrasso
Copy link
Author

germangrasso commented Sep 30, 2016

Hi @HookyQR,
I have ruby-debug-ide (0.6.1.beta2) installed and debase (0.2.2.beta8, 0.2.1). If I create a new rails app with "rails new" I do can debug it. What I see is that the app I am having trouble with, doesn't have rails executable in the <app>/bin folder. It's relying on the rails executable in my gemset folder:
~/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails
Could this be related?

@HookyQR
Copy link
Contributor

HookyQR commented Sep 30, 2016

It shouldn't be, the lack of output suggest to me that it's not finding the debugger rather than not finding rails. Try putting in a simple script in you base directory and running that with the debugger. If that doesn't run, then it's the debugger that isn't found, as I expect. You can point VS code to the debugger executable with a "pathToRDebugIDE": "/path/to/rdebug-ide" in your launch configuration.

@germangrasso
Copy link
Author

I tried adding the simple script and it works. So the debugger is definitely found. I do see something in the Output windows for the extension: "waiting for debug protocol on stdin/stdout". Nothing else.

@HookyQR
Copy link
Contributor

HookyQR commented Sep 30, 2016

Can you please add "showDebuggerOutput": true, to your config and give me the output from that.

@germangrasso
Copy link
Author

germangrasso commented Sep 30, 2016

The debug console shows now "Fast Debugger (ruby-debug-ide 0.6.1.beta2, debase 0.2.2.beta8, file filtering is supported) listens on 127.0.0.1:1234". But it terminates.

@HookyQR
Copy link
Contributor

HookyQR commented Sep 30, 2016

That's the correct output. Add some output to your script, and see if that comes out on the debug console. (puts "Hello world")

@germangrasso
Copy link
Author

@HookyQR debugging the script does work. It does hit my breakpoint and writes to the output window my puts "Hello world".
It's the rails server configuration debugging that still doesn't work. It outputs "Fast Debugger (ruby-debug-ide 0.6.1.beta2, debase 0.2.2.beta8, file filtering is supported) listens on 127.0.0.1:1234" the status bar blinks red and the bar with the "Continue", Step Into, Step Out, Stop buttons disappear.

@germangrasso
Copy link
Author

By the way, thanks for helping out!

@HookyQR
Copy link
Contributor

HookyQR commented Sep 30, 2016

Ok, so it's good that the script debug is working fully. (That confirms that it's not the debugger at all, sorry to put you through all that.) Can you check the file at /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails and make sure it is a ruby script and not a shell script.

Also, you can open VS Code's console from Help->Toggle Developer Tools, then open the console tab. Clear it before you launch the debug (if it's not all ready clear) and you may get some output there to help.

@HookyQR
Copy link
Contributor

HookyQR commented Sep 30, 2016

Also, to check that everything would work correctly from a terminal with the same settings as VS Code is trying to run, open the internal terminal (Ctrl+``) and run the command that you're asking the debugger to run:/home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails server`.

@germangrasso
Copy link
Author

ok, so:

  1. /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails is a ruby script.
  2. I get nothing in the Dev Tools console.
  3. I can run /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rails server from the VS Code console without problems.

I found something interesting, if I add the "useBundler": true, option I start getting this error:

/home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:373:in block in replace_bin_path': can't find executable rdebug-ide (Gem::Exception)
from /home/AMER/ggrasso/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb:298:in activate_bin_path' from /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rdebug-ide:22:in

'
from /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/ruby_executable_hooks:15:in eval' from /home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/ruby_executable_hooks:15:in '`

I tried adding the pathToRDebugIDE option like this "pathToRDebugIDE": "/home/AMER/ggrasso/.rvm/gems/ruby-2.3.1@unisporkal/bin/rdebug-ide" but it made no difference.

@Abrakazoo
Copy link

@germangrasso were you able to resolve this issue?

@hickey
Copy link

hickey commented May 12, 2017

For anyone else that runs into this problem (I hate it when there is a problem but never any solution offered), it is because VS Code is getting started outside of the terminal environment and rvm is being used to manage how to find the bits of Ruby. In order for the Ruby debugger to work under VS Code and cooperate with rvm, there are a number of environmental variables that need to be set.

{
    "name": "Debug replicate-puppet-environment",
    "type": "Ruby",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "program": "${workspaceRoot}/replicate-puppet-environment",
    "pathToRDebugIDE": "/Users/ghickey/.rvm/gems/ruby-2.2.4/gems/ruby-debug-ide-0.6.0/bin/rdebug-ide",
    "env": {
        "PATH": "/Users/ghickey/.rvm/gems/ruby-2.2.4/bin:/Users/ghickey/.rvm/gems/ruby-2.2.4@global/bin:/Users/ghickey/.rvm/rubies/ruby-2.2.4/bin:/Users/ghickey/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/ghickey/.rvm/bin:/Users/ghickey/.rvm/bin",
        "rvm_prefix": "/Users/ghickey",
        "rvm_path": "/Users/ghickey/.rvm",
        "rvm_bin_path": "/Users/ghickey/.rvm/bin",
        "GEM_HOME": "/Users/ghickey/.rvm/gems/ruby-2.2.4",
        "GEM_PATH": "/Users/ghickey/.rvm/gems/ruby-2.2.4:/Users/ghickey/.rvm/gems/ruby-2.2.4@global",
        "MY_RUBY_HOME": "/Users/ghickey/.rvm/rubies/ruby-2.2.4",
        "IRBRC": "/Users/ghickey/.rvm/rubies/ruby-2.2.4/.irbrc",
        "RUBY_VERSION": "ruby-2.2.4"
     }
}

There are probably a few of those that don't need to be created (specifically rvm_*), but that is what was showing up in my environment so I created them. My path could be adjusted some also.

If I were to guess, I would say that only PATH, GEM_HOME, GEM_PATH and RUBY_VERSION only need to be put in the environment.

Update: I was just able to confirm that the 4 variables above are the only ones really needing to be specified.

@bugg2844
Copy link

I had a similar issue. The solution was instead of trying to update the path to rails, simply generate binstubs so the default path ${workspaceRoot}/bin/rails works. For our Rails 4 app that was $ rake rails:update:bin. For a Rails 5 app it may be different (possibly rails app:update:bin?)

@alex1704
Copy link

alex1704 commented Jun 5, 2019

Deleting all breakpoints worked for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants