【问题标题】:Cannot access Rails console in Windows - LoadError无法在 Windows 中访问 Rails 控制台 - LoadError
【发布时间】:2015-09-25 19:21:40
【问题描述】:

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

我尝试了解决方案“Load error when running 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 扩展,因此问题与那个问题不重复。

【问题讨论】:

标签: ruby-on-rails ruby jruby


【解决方案1】:

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

http://jruby.org/getting-started

然后从项目的根目录执行bundle

【讨论】:

  • 未安装 jruby,删除 jruby 目录,安装 jruby,安装 bundle,运行 bundle,安装所有 gem。同样的问题。
【解决方案2】:

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

我从未解决过让rails console 工作的问题。这可能与我的 ruby​​ 安装是 jRuby 的一部分有关。

但是,irbjirb 允许我使用命令提示符或 Powershell 在命令行上执行 Ruby sn-ps。 GitBash 不工作,说Switch to inspect mode. 后跟&gt;&gt; 然后退出。

【讨论】:

    猜你喜欢
    • 2016-09-10
    • 2019-07-29
    • 1970-01-01
    • 2013-06-23
    • 2014-05-19
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 2020-01-03
    相关资源
    最近更新 更多