1

我正在通过 rvm 运行 JRuby-1.7.3。我已经成功安装了em-websocket-server gem。我可以通过运行$ gem list来验证它是否在我当前的 gemset中。

我的代码是这样的:

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

当我尝试运行它时,我收到以下错误:

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

有什么建议么?

4

2 回答 2

1

我有完全相同的错误,因为我直接使用 gem 命令而不是 jruby gem 命令。

要解决这个问题,只需运行:

jruby -S gem install em-websocket

这对我有用,希望这对你也有帮助。

于 2013-06-03T05:42:09.377 回答
0

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.

于 2013-06-12T10:13:55.673 回答