jruby 没有要加载的文件 application.rb

jruby no such file to load application.rb

我有一个 jRuby 项目,我尝试 运行。 所以我像这样使用 rvm 安装 jruby

rvm install jruby-9.1.15.0(bc 那是项目需要的版本)

然后我通过键入来确保我实际使用了 jruby ruby -v 这表明我有 jruby

接下来,我想 运行 rails 服务器,所以我输入

bundle exec rails server

不幸的是我得到一个错误:

/Users/foouser/Documents/Projects/fooproject/bin/config/application
LoadError: no such file to load -- /Users/foouser/Documents/Projects/fooproject/bin/config/application
          require at org/jruby/RubyKernel.java:955
  block in server at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78
              tap at org/jruby/RubyKernel.java:1741
           server at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75
     run_command! at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39
           <main> at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands.rb:17
          require at org/jruby/RubyKernel.java:955
           <main> at bin/rails:5

我试过谷歌搜索但无济于事。人们似乎根本没有遇到这个问题。我确定这与我的设置有关,因为其他人已成功使用该项目。

有什么想法吗?

rails 版本 - 4.2 jruby 版本 - 9.1.15.0

编辑:

经过一些挖掘,在 bin/rails 文件中定义 APP_PATH 的行是这样的:

APP_PATH = File.expand_path('../config/application', __FILE__)

这不知何故使它在 fooproject/bin/config 而不是 fooproject/config

中寻找 application.rb

但是当我将行更改为

APP_PATH = File.expand_path('../../config/application', __FILE__)

它转到 application.rb 存在的正确路径,但仍然报告它不存在。

错误几乎相同(除了路径)

LoadError: no such file to load -- /Users/foouser/Documents/Projects/fooproject/config/application
          require at org/jruby/RubyKernel.java:955
  block in server at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78
              tap at org/jruby/RubyKernel.java:1741
           server at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75
     run_command! at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39
           <main> at /Users/foouser/.rvm/gems/jruby-9.1.15.0-jrubu/gems/railties-4.2.10/lib/rails/commands.rb:17
          require at org/jruby/RubyKernel.java:955
           <main> at bin/rails:4

编辑 2:

请求 application.rb 的权限:

-rw-r--r-- 1 foouser staff 5818 20 Jun 15:12 config/application.rb

config.ru:

# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment',  __FILE__)
run Rails.application

environment.rb

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!

所以,我的解决方案是"have you tried to turn it off and on again?"类型。 我删除了整个项目并从 repo 中再次克隆了它。 现在一切正常,它一定是我本地环境的问题,但我不知道是什么。

无论如何,如果您遇到类似的情况 - 清除和克隆绝对是您可以尝试的方法。