无法访问Windows中的Rails控制台 - LoadError

时间:2015-09-25 19:21:40

标签: ruby-on-rails ruby jruby

我使用的是JRuby,因为它对Windows上的SRS Ruby on Rails更好。

我的解决方案是在cmd.exe或Powershell(而不是gitbash)中使用jirb

我试过了:

$ rails console
Loading development environment (Rails 4.2.4)
Switch to inspect mode.
LoadError: load error: rails/commands -- java.lang.UnsatisfiedLinkError: The operation completed successfully.

  require at org/jruby/RubyKernel.java:939
    <top> at bin/rails:4

$ bundle exec rails console
uri:classloader:/jruby/kernel/kernel.rb:17: warning: unsupported exec option: close_others
Loading development environment (Rails 4.2.4)
Switch to inspect mode.
LoadError: load error: rails/commands -- java.lang.UnsatisfiedLinkError: The operation completed successfully.

  require at org/jruby/RubyKernel.java:939
    <top> at bin/rails:4

$ jruby.exe -S bundle exec rails console
uri:classloader:/jruby/kernel/kernel.rb:17: warning: unsupported exec option: close_others
Loading development environment (Rails 4.2.4)
Switch to inspect mode.
LoadError: load error: rails/commands -- java.lang.UnsatisfiedLinkError: The operation completed successfully.

  require at org/jruby/RubyKernel.java:939
    <top> at bin/rails:4

我尝试了解决方案&#34; Load error when running rails console&#34;,但重新启动计算机无效。 bin / spring没有提到GEM_HOME。我重新安装了Rails和Spring。

这是因为JRuby?

我很高兴jruby -S rails console需要C扩展的想法。我找到了另一种使用JRuby自己的jirc访问控制台的方法。我开始时:

$ jirb
Switch to inspect mode.

然后编辑〜/ .irbrc以包含

IRB.conf[:PROMPT_MODE] = :SIMPLE

产生:

$ jirb
Switch to inspect mode.
>>

然后立即退出。这样做:

$ jirb puts 'hello'
Switch to inspect mode.
Errno::ENOENT: No such file or directory - puts
  initialize at org/jruby/RubyFile.java:342
        open at org/jruby/RubyIO.java:1124
        open at G:/jruby-9.0.1.0/lib/ruby/stdlib/irb/magic-file.rb:7
  initialize at G:/jruby-9.0.1.0/lib/ruby/stdlib/irb/input-method.rb:100
  initialize at G:/jruby-9.0.1.0/lib/ruby/stdlib/irb/context.rb:84
  initialize at G:/jruby-9.0.1.0/lib/ruby/stdlib/irb.rb:426
       start at G:/jruby-9.0.1.0/lib/ruby/stdlib/irb.rb:381
       <top> at G:/jruby-9.0.1.0/bin/jirb:13

由于我的控制台仍无法正常工作,并且jirc没有使用C扩展,因此该问题与该控件不重复。

2 个答案:

答案 0 :(得分:0)

是的,我会尝试安装jruby来解决这个问题

请参阅http://jruby.org/getting-started

然后从项目的根目录<{1}}

答案 1 :(得分:0)

TL; DR在命令提示符中使用jirb来执行Ruby代码。

我从未决定让rails console工作。这可能与我的ruby安装有关,这是jRuby的一部分。

但是,irbjirb允许我使用命令提示符或Powershell在命令行上执行Ruby代码段。 GitBash不起作用,Switch to inspect mode.后跟>>,然后退出。