我使用的是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扩展,因此该问题与该控件不重复。
答案 0 :(得分:0)
答案 1 :(得分:0)
TL; DR在命令提示符中使用jirb
来执行Ruby代码。
我从未决定让rails console
工作。这可能与我的ruby安装有关,这是jRuby的一部分。
但是,irb
和jirb
允许我使用命令提示符或Powershell在命令行上执行Ruby代码段。 GitBash不起作用,Switch to inspect mode.
后跟>>
,然后退出。