[英]Unable to create an EXE file from Ruby script
I am unable to create an EXE file from Ruby script. 我无法从Ruby脚本创建EXE文件。
require 'socket'
class Server
def initialize(ip, port)
@server = TCPServer.open(ip, port)
@clients = Array.new
run
end
def run
loop {
Thread.start(@server.accept) do |client|
@clients << client
client.puts 'Connection established'
listen_user_messages(client)
end
}.join
end
def listen_user_messages(client)
loop {
msg = client.gets.chomp
@clients.each do |other_client|
if other_client != client
other_client.puts "#{msg}"
end
end
}
end
end
Server.new('localhost', 19937)
I'm trying to run the following command: 我正在尝试运行以下命令:
ocra server.rb ocra server.rb
but it freezes on the message 但它在消息上冻结了
=== Loading script to check dependencies ===加载脚本以检查依赖项
I've also tried to use exerb: 我也尝试过使用exerb:
ruby exerb server.rb ruby exerb server.rb
It builds an exe file, but I am unable to use it: 它构建一个exe文件,但我无法使用它:
server.rb:1:in `require': No such file to load -- socket (LoadError) from server.rb:1 server.rb:1:在`require':没有这样的文件加载 - 来自server.rb的socket(LoadError):1
require 'socket'
require 'rubygems'
exit if Object.const_defined?(:Ocra) #allow ocra to create an exe without executing the entire script
Add the above to your script, this should allow it to generate. 将上面的内容添加到您的脚本中,这应该允许它生成。 Ocra cannot see ruby gems and other files at times if you don't include 'rubygems' 如果你不包括'rubygems',Ocra有时看不到红宝石和其他文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.