RedFred
RedFred

Reputation: 1039

why can't I run em-websocket-server on JRuby?

I'm running JRuby-1.7.3 through rvm. I've successfully installed the em-websocket-server gem. I can verify it's in my current gemset by running $ gem list.

My code is this:

require 'rubygems'
require 'em-websocket-server'

class EchoServer < EM::WebSocket::Server

  def on_connect
    EM::WebSocket::Log.debug "Connected"
  end

  def on_receive msg
    send_message msg
  end

end

EM.run do
    EM.start_server "0.0.0.0", 8000, EchoServer
end

When I try to run it, I get the following error:

LoadError: no such file to load -- em-websocket-server require at org/jruby/RubyKernel.java:1027 require at /home/dev1/.rvm/rubies/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:36

Any suggestions?

Upvotes: 1

Views: 644

Answers (2)

RedFred
RedFred

Reputation: 1039

The problem actually solved itself after I removed rvm ($ rvm implode) and re-installed it

$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install jruby

I then installed all my gems in the default gemset. em-websocket-server was then picked up and worked fine. I can only attribute this to some twisted configuration or even bug in my original rvm setup.

Upvotes: 0

markdrake
markdrake

Reputation: 624

I had the exact same error because I was using the gem command directly instead of the jruby gem command.

To fix this just run:

jruby -S gem install em-websocket

This worked for me, hope this helps you too.

Upvotes: 1

Related Questions