Remote Ruby SshjSshConnection Fatal Error in RubyMine and Not Fatal in Intellij IDE

Completed

The same project with remote Ruby with rbenv and Rails 4 using SSH/sftp succeeds in IntellliJ 2018.3.1 succeeds (but with errors in idea.log), but fails in RubyMine 2019.2.1 and 2019.2 starting Deployment Run or Debug in any mode.

  • sftp testing succeeds in settings.
  • Guest/Host Port binding 3000

 

RubyMine Deployment fails with this logs:

Output in IDE:

Error running 'Development': Failed to create local tunnel for SshjSshConnection(<crc32=bie7tb>@localhost)@108601b9: localhost:3000 <== localhost:3000: Address already in use: NET_Bind

Logs:

(2019-08-23 14:15:42,869 [ 20726] WARN - nsight.nativerb.StubsGenRunner - Unable to build stubs for remote sdk: Remote: ruby-2.5.5-p157: ver.2.5.5p157 ( revision 67260) p157 (ssh://xxxx@localhost:yyy/opt/rbenv/versions/2.5.5/bin/ruby) 

2019-08-23 14:16:26,561 [ 64418] INFO - .channel.direct.SessionChannel - Will request `sftp` subsystem
2019-08-23 14:16:26,734 [ 64591] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from remote server 127.0.0.1:3000 to local localhost:3000]
2019-08-23 14:16:26,736 [ 64593] WARN - om.intellij.ssh.impl.sshj.sshj - Failed to create local tunnel for SshjSshConnection(<crc32=bie7tb>@localhost)@108601b9: localhost:3000 <== localhost:3000: Address already in use: NET_Bind
java.net.BindException: Address already in use: NET_Bind
at java.base/java.net.PlainSocketImpl.bind0(Native Method)
at java.base/java.net.PlainSocketImpl.socketBind(PlainSocketImpl.java:132)

 

Intellij Deployment succeeds, with this logs:

IntelliJ idea.log:

2019-08-23 14:03:46,133 [ 29949] WARN - nsight.nativerb.StubsGenRunner - Unable to build stubs for remote sdk: Remote: ruby-2.5.5-p157: ver.2.5.5p157 ( revision 67260) p157 (ssh://xxx@localhost:xx/opt/rbenv/versions/2.5.5/bin/ruby)
2019-08-23 14:03:47,270 [ 31086] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from remote server localhost:34296 to local localhost:49473]
2019-08-23 14:03:47,272 [ 31088] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from local server localhost:49474 to remote localhost:48758]
2019-08-23 14:03:47,275 [ 31091] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from remote server 127.0.0.1:3000 to local localhost:3000]
2019-08-23 14:03:47,276 [ 31092] WARN - n.RubyAbstractCommandLineState - Unable to add tunnel
com.intellij.remote.RemoteSdkException: Failed to add local port forwarding
at com.intellij.ssh.process.SshProcess.addLocalTunnel(SshProcess.java:101)
at org.jetbrains.plugins.ruby.remote.RubyRemoteProcessHandler.addTunnel(RubyRemoteProcessHandler.java:64)
at org.jetbrains.plugins.ruby.ruby.run.configuration.RubyAbstractCommandLineState.createCommandLineAndProcessHan

[same cause as below]


2019-08-23 14:06:23,529 [ 187345] INFO - emote.RubyRemoteProcessHandler - processWillTerminate: removing port forwarding - Port forwarding[from remote server localhost:34296 to local localhost:49473]
2019-08-23 14:06:46,664 [ 210480] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from remote server localhost:41837 to local localhost:49981]
2019-08-23 14:06:46,664 [ 210480] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from local server localhost:49982 to remote localhost:56691]
2019-08-23 14:06:46,666 [ 210482] INFO - emote.RubyRemoteProcessHandler - Adding new tunnel - Port forwarding[from remote server 0.0.0.0:3000 to local localhost:3000]
2019-08-23 14:06:46,667 [ 210483] WARN - n.RubyAbstractCommandLineState - Unable to add tunnel
com.intellij.remote.RemoteSdkException: Failed to add local port forwarding
at com.intellij.ssh.process.SshProcess.addLocalTunnel(SshProcess.java:101)
at org.jetbrains.plugins.ruby.remote.RubyRemoteProcessHandler.addTunnel(RubyRemoteProcessHandler.java:64)
at org.jetbrains.plugins.ruby.ruby.run.configuration.RubyAbstractCommandLineState.createCommandLineAndProcessHandler(RubyAbstractCommandLineState.java:163)
at org.jetbrains.plugins.ruby.rails.run.configuration.server.RailsServerRunCommandLineState.createCommandLineAndProcessHandler(RailsServerRunCommandLineState.java:136)
at org.jetbrains.plugins.ruby.ruby.debugger.RubyDebugRunner$RubyDebugSessionBuilder.<init>(RubyDebugRunner.java:185)
....

aused by: com.intellij.ssh.SshTransportException: Failed to add local port forwarding
at com.intellij.ssh.SshSession.addLocalTunnel(SshSession.kt:48)
at com.intellij.ssh.process.SshProcess.addLocalTunnel(SshProcess.java:98)
... 51 more
Caused by: com.jcraft.jsch.JSchException: PortForwardingL: local port 127.0.0.1:3000 cannot be bound.
at com.jcraft.jsch.PortWatcher.<init>(PortWatcher.java:158)
at com.jcraft.jsch.PortWatcher.addPort(PortWatcher.java:110)
at com.jcraft.jsch.Session.setPortForwardingL(Session.java:1847)
at com.jcraft.jsch.Session.setPortForwardingL(Session.java:1828)
at com.jcraft.jsch.Session.setPortForwardingL(Session.java:1809)
at com.jcraft.jsch.Session.setPortForwardingL(Session.java:1792)
at com.intellij.ssh.SshSession.addLocalTunnel(SshSession.kt:45)
... 52 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
at java.net.TwoStacksPlainSocketImpl.socketBind(Native Method)
at java.net.TwoStacksPlainSocketImpl.socketBind(TwoStacksPlainSocketImpl.java:137)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
at java.net.TwoStacksPlainSocketImpl.bind(TwoStacksPlainSocketImpl.java:110)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
at java.net.ServerSocket.bind(ServerSocket.java:375)

 

Apparently the connection to the remote/guest system seems to fail in both cases - but not really fatal, as IntelliJ could execute the remote commands! False positives?!

 

0
7 comments
Avatar
Permanently deleted user

Thank you for your answer!  Yes, this helps - partially at least. I now can run the server from remote successfully, but not in debugging mode (debug). I get another error stack now:

/opt/rbenv/versions/2.5.5/bin/ruby /xxx/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.8.0.beta6/bin/rdebug-ide --key-value --step-over-in-blocks --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 54841 --host 0.0.0.0 --dispatcher-port 51312 -- /xxx/__MY_RAILS_4_APP__/bin/rails server -b 127.0.0.1 -p 3000 -e development -b 0.0.0.0
Traceback (most recent call last):
4: from /xxx/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.8.0.beta6/bin/rdebug-ide:192:in `<main>'
3: from /xxx/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:97:in `debug_program'
2: from /xxxe/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:86:in `prepare_debugger'
1: from /xxx/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:78:in `start_server'
/xxx/.gem/ruby/2.5.0/gems/debase-0.3.0.beta7/lib/debase.rb:71:in `start': undefined local variable or method `disable_all_iseqs' for Debase:Module (NameError)
Did you mean? disable_tp_on_iseq

Process finished with exit code 1

 

 

0

Just to be sure, does the same happen in 2019.2.2 Preview? Does it happen to every Rails project?

0
Avatar
Permanently deleted user

It resolved after I realized, that debase gem dependency was not build correctly on the remote machine, gcc version was 4.7.1. It compiled with gcc 4.9.2.

mkmf.log

"gcc -o conftest -I/opt/rbenv/versions/2.5.5/include/ruby-2.5.0/i686-linux -I/opt/rbenv/versions/2.5.5/include/ruby-2.5.0/ruby/backward -I/opt/rbenv/versions/2.5.5/include/ruby-2.5.0 -I. -I/opt/rbenv/versions/2.5.5/include -D_FILE_OFFSET_BITS=64 -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn conftest.c -L. -L/opt/rbenv/versions/2.5.5/lib -Wl,-rpath,/opt/rbenv/versions/2.5.5/lib -L. -L/opt/rbenv/versions/2.5.5/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/rbenv/versions/2.5.5/lib -L/opt/rbenv/versions/2.5.5/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */

 

gem_make.out

...

checking for vm_core.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/rbenv/versions/2.5.5/bin/$(RUBY_BASE_NAME)
--with-ruby-dir
--without-ruby-dir
--with-ruby-include
--without-ruby-include=${ruby-dir}/include
--with-ruby-lib
--without-ruby-lib=${ruby-dir}/lib
/opt/rbenv/versions/2.5.5/lib/ruby/2.5.0/mkmf.rb:456:

 

Rails projects with older debugger (debug-ide-0.7) seem not to be concerned and a new project started the debug session sucessfully after the project SDK was updated correctly (in system/ruby_stubs/*/rbenv/versions/*/bin):

...
Fast Debugger (ruby-debug-ide 0.8.0.beta6, debase 0.3.0.beta7, file filtering is supported, block breakpoints supported, smart steps supported, obtaining return values supported) listens on 0.0.0.0:44965
=> Booting WEBrick

Thanks!

 

0

Thanks for the update, good to know you've solved the problem!

0

I am having this error, just trying to use ruby 2.6.3 on Mojave. No JVM involved, so I can't use the advice about sshj.

0

Guyren,

does it happen in the latest 2019.3 EAP as well? Which error do you get?

0

Please sign in to leave a comment.