簡體   English   中英

無法在Windows中訪問Rails控制台-LoadError

[英]Cannot access Rails console in Windows - LoadError

我使用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

我嘗試了解決方案“ 運行rails console時出現加載錯誤 ”,但是重新啟動計算機沒有任何效果。 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擴展,因此問題不在於該擴展。

是的,我會嘗試安裝jruby來解決此問題

參見http://jruby.org/getting-started

然后從項目的根進行bundle

TL; DR在命令提示符中使用jirb執行Ruby代碼。

我從來沒有解決過讓rails console工作的問題。 這可能與我的ruby安裝是jRuby的一部分有關。

但是, irbjirb允許我使用Command Prompt或Powershell在命令行上執行Ruby代碼段。 Switch to inspect mode.說,GitBash不起作用Switch to inspect mode. 然后是>> ,然后退出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM