运行ruby脚本时出错

时间:2016-09-28 03:16:59

标签: ruby-on-rails ruby windows-7 rubygems stomp

我正在尝试运行一个ruby脚本,它基本上是一个调用ActiveMQ代理的Stomp客户端。

当我运行脚本时,我收到此错误:

going to startC:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:5
4:in `require': cannot load such file -- stomp (LoadError)
        from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
:in `require'
        from C:/Users/lokesh.kumar/Documents/issues/ActiveMQ-slowness/activemq-c
acti-plugin.rb:34:in `<main>'

以下是命令gem env

的结果
C:\Users\lokesh.kumar>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5.1
  - RUBY VERSION: 2.2.5 (2016-04-26 patchlevel 319) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby22-x64/lib/ruby/gems/2.2.0
  - RUBY EXECUTABLE: C:/Ruby22-x64/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby22-x64/bin
  - SPEC CACHE DIRECTORY: Z:/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby22-x64/lib/ruby/gems/2.2.0
     - Z:/.gem/ruby/2.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - C:\oracle\product\11.2.0\client_1\bin
     - C:\Windows\system32
     - C:\Windows
     - C:\Windows\System32\Wbem
     - C:\Windows\System32\WindowsPowerShell\v1.0\
     - C:\Program Files\TortoiseHg\
     - C:\Program Files\TortoiseSVN\bin
     - C:\Program Files (x86)\Enterprise Vault\EVClient\
     - C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
     - C:\Program Files (x86)\GitExtensions\
     - C:\Program Files (x86)\AMD\ATI.ACE\Core-Static
     - C:\Program Files (x86)\Skype\Phone\
     - c:\Program Files\TortoiseGit\bin
     - C:\Ruby22-x64\bin
     - C:\Users\lokesh.kumar\.babun
     - D:\Installations\apache-maven-3.2.5\bin
     - C:\Program Files\Java\jdk1.8.0_91\bin

我从未在Ruby工作过,所以这可能是一个基本的安装错误。有什么指针可以解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

好像你没有安装NX gem 您可以使用argv[1]安装任何所需的宝石。

在您的特定情况下,#define _GNU_SOURCE #include <stdio.h> #include <unistd.h> #include <sys/syscall.h> void shellcode(void) { static char buf[] = "shellcode: hello\n"; char *cp; for (cp = buf; *cp != 0; ++cp); // NOTE: in real shell code, we couldn't rely on using this function, so // these would need to be the CPP macro versions: _syscall3 and _syscall2 // respectively or the syscall function would need to be _statically_ // linked in syscall(SYS_write,1,buf,cp - buf); syscall(SYS_exit,0); } int main(int argc,char **argv) { void *retadr = __builtin_return_address(0); void **fp = __builtin_frame_address(0); int iter; printf("retadr=%p\n",retadr); printf("fp=%p\n",fp); // NOTE: for your example, replace: // *fp = (void *) shellcode; // with: // *fp = (void *) argv[1] for (iter = 20; iter > 0; --iter, fp += 1) { printf("fp=%p %p\n",fp,*fp); if (*fp == retadr) { *fp = (void *) shellcode; break; } } if (iter <= 0) printf("main: no match\n"); return 0; } stomp 因此,请尝试运行gem install GEMNAME并再次运行您的脚本。

P.S。
默认情况下,GEMNAME命令使用rubygems作为宝石源 因此,您可以随时查看宝石名称。