【问题标题】:Error when loading Rails server (Rails 4)加载 Rails 服务器时出错(Rails 4)
【发布时间】:2015-01-30 22:17:03
【问题描述】:

我有一个正在运行的应用程序没有问题,并且刚刚进行了捆绑更新和捆绑安装,现在。

我想我在过去的 4 个月里没有更新过捆绑包。

现在当我运行$ rails s 时,我遇到了这个错误:

".../gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read': Is a directory - .../public/assets (Errno::EISDIR)"!

mathieu-To-be-filled-by-O-E-M:~/rails_projects/mathieu_app$ rails s
DEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from require at /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76)
=> Booting WEBrick
=> Rails 4.0.12 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
DEPRECATION WARNING: Model based mass assignment security has been extracted
out of Rails into a gem. Please use the new recommended protection model for
params or add `protected_attributes` to your Gemfile to use the old one.

To disable this message remove the `whitelist_attributes` option from your
`config/application.rb` file and any `mass_assignment_sanitizer` options
from your `config/environments/*.rb` files.

See http://guides.rubyonrails.org/security.html#mass-assignment for more information.

Exiting
/home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read': Is a directory - /home/mathieu/rails_projects/mathieu_app/public/assets (Errno::EISDIR)
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `initialize'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/sprockets-rails-2.2.2/lib/sprockets/railtie.rb:105:in `new'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/sprockets-rails-2.2.2/lib/sprockets/railtie.rb:105:in `block in <class:Railtie>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:36:in `call'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:30:in `run'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /home/mathieu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/application.rb:215:in `initialize!'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/mathieu/rails_projects/mathieu_app/config/environment.rb:5:in `<top (required)>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `require'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `block in require'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/activesupport-4.0.12/lib/active_support/dependencies.rb:229:in `require'
    from /home/mathieu/rails_projects/mathieu_app/config.ru:3:in `block in <main>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /home/mathieu/rails_projects/mathieu_app/config.ru:in `new'
    from /home/mathieu/rails_projects/mathieu_app/config.ru:in `<main>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands/server.rb:48:in `app'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@global/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands/server.rb:75:in `start'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:71:in `tap'
    from /home/mathieu/.rvm/gems/ruby-2.0.0-p451@rails3tutorial2ndEd/gems/railties-4.0.12/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我的宝石清单:

source 'https://rubygems.org'
ruby "2.0.0"                  # source: https://devcenter.heroku.com/articles/ruby-versions

# Rails 4
gem 'rails', "~> 4.0.3"
# Gems supporting Rails 4 core architecture
gem 'actionpack-action_caching'
gem 'actionpack-page_caching'
gem 'activerecord-session_store'
gem 'activeresource'
gem 'rails-observers'
gem 'turbolinks'

gem 'pg'
gem 'anjlab-bootstrap-rails', :require  => 'bootstrap-rails',
                              :github   => 'anjlab/bootstrap-rails',
                              :branch   => '3.0.0'
gem 'devise'                  # authentification
gem 'cancan'                  # authorization
gem 'rolify',                 :git => 'git://github.com/EppO/rolify.git' # role management library with resource scoping, added fork due to bug source - stackoverflow.com/questions/13712012/error-pushing-to-heroku-aborting-my-rake-assetsprecompile?rq=1 
gem 'figaro'                  # rails app configuration and keep private stuff...private
gem 'sendgrid'                # sendgrid gem
gem 'faker'                   # to create fake user accounts
gem 'will_paginate'           # pagination method
gem 'bootstrap-will_paginate' # configure will_paginate gem to bootstrap pagination style
gem 'font-awesome-rails'      # pure css icons
gem 'validates_timeliness'    # methods and validations for dates formats
gem 'validate_url'            # for URL validations in forms
gem 'dotiw'                   # overrides the default distance_of_time_in_words and provides a more accurate output 
gem 'friendly_id'             

# Forms with formtastic
gem 'formtastic'
gem 'formtastic-bootstrap'

# Active admin stuff
gem 'activeadmin',            github: 'gregbell/active_admin' # added github because of deployment issue wiht jquery ui http://stackoverflow.com/questions/16844411/rails-active-admin-deployment-couldnt-find-file-jquery-ui
gem 'sass-rails',             '~> 4.0.1' # Master branch not OK with Rails 4, hence we point to branch that comply with Rails 4
gem 'kaminari'                #'0.14.1' active admin needs kaminari for pagination; blocked on 0.14.1 because if not get nomethod error per_page kaminari https://github.com/sferik/rails_admin/issues/1868 and https://github.com/amatsuda/kaminari/issues/481
gem 'postgres_ext'            # gives a nice set of query methods & Adds missing native PostgreSQL data types to ActiveRecord and convenient querying extensions for ActiveRecord and Arel for Rails 4.x

gem 'jquery-rails'
gem 'chosen-rails'            
gem 'coffee-rails',           '~> 4.0.1' # Master branch not OK with Rails 4, hence we point to branch that comply with Rails 4 by default 
gem 'uglifier'                

# Geocoding and locations
gem 'geocoder'                
gem 'country-select'          

group :production do
  gem 'rails_12factor'        
end     


group :development do
  gem 'quiet_assets'          # mutes assets pipeline log messages
  gem 'better_errors'         # improve error pages
  # retrieve  binding of a method's caller in MRI 1.9.2+, only for debugging
  gem 'binding_of_caller', platforms: [:mri_19, :rbx]
end


group :development, :test do
  gem 'perftools.rb',         require: 'perftools' # used to find tasks taking long time (ex when test are too long)
  gem 'guard',                '>=2.1.0'
  gem 'guard-rspec'
  gem 'guard-rails-assets'    
  gem 'rspec-rails'
  gem 'factory_girl_rails'    
  gem 'pry-rails'             
  gem 'rspec-collection_matchers' 
  gem 'i18n-tasks'            
end

group :test do
  gem 'capybara'
  gem 'selenium-webdriver'     -ex: flash error messages...
  gem 'capybara-webkit'        -ex: flash error messages...
  gem 'rb-inotify'            
  gem 'libnotify'
  gem 'database_cleaner'      
  gem 'email_spec'            
  gem 'cucumber-rails',       :require => false   #
  gem 'launchy'               
  gem 'shoulda-matchers'      
  gem 'minitest'              
  gem 'guard-zeus-client'     

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4


    【解决方案1】:

    在 development.rb 中删除或注释掉这行代码即可解决问题:

    config.assets.manifest = Rails.root.join("public/assets")
    

    【讨论】:

      【解决方案2】:

      如果您查看 sprockets gem 的 source code(错误来自哪里),您可以看到这些行引发了错误:

      63  begin
      64    if File.exist?(@path)
      65      data = json_decode(File.read(@path))
      66    end
      67  rescue MultiJson::DecodeError => e
      68    logger.error "#{@path} is invalid: #{e.class} #{e.message}"
      69  end
      

      第 65 行是问题所在,特别是 File.read(@path) - 如您的错误消息所示 (sprockets-2.12.3/lib/sprockets/manifest.rb:65:in `read ')。

      基本上,@path 应该是一个代表文件名的字符串,但它实际上指向一个目录,这导致File.read 失败。 @path 应该指向您资产的清单文件(通常由 Sprockets 自动创建),我不确定为什么它在这里得到不正确的路径 - 您是否有任何与 config/application.rb 中的清单文件相关的内容或在您的环境配置文件中? app/assets/javascripts/application.jsapp/assets/stylesheets/application.css 呢?

      尝试自己编辑 sprockets 的本地副本(从应用程序目录运行“cd `bundle show sprockets`”以找到它)并在上面的第 65 行之前添加puts @path(请确保记住在使用时将其删除)重新完成!) - 它说什么?

      【讨论】:

      • 和“我不知道为什么这里的路径不正确” => 在进行此捆绑更新之前,我试图提交并遇到资产问题,所以我做了 rails:asset:clobber, rails assets:precompile ...也许是什么导致了问题?
      • 我对“清单”一词进行了搜索,不,它不在 application.rb、javascript/application.js 和 application.css 上。它在 config/environments/development.rb 上:config.assets.manifest = Rails.root.join("public/assets")
      • 我现在要试试你推荐的东西
      • config.assets.manifest = Rails.root.join("public/assets") 可能是罪魁祸首。 assets:precompile 应该在您的 public 目录中的某处创建了一个名为 manifest.json 的文件 - 如果我没记错的话,config.assets.manifest 应该指向这个文件。是吗?
      • 哇哇!!!!!!我注释掉了 config.assets.manifest = Rails.root.join("public/assets") 并且它有效
      【解决方案3】:

      嗯...有没有可能你有 Sprocket 并且结构已经改变,或者类似的东西?

      您是否尝试过删除该目录(或只是重命名它)?这家伙删除了错误提到的目录,它工作正常:Trying to install rails- EISDIR error

      好像有更新的版本,你试过更新吗? (https://rubygems.org/gems/sprockets-rails)

      注意:这应该是评论,但我没有足够的声誉......

      【讨论】:

      • sprockets 2.12.3 和 sprockets-rails 2.2.2 是撰写本文时最新的稳定版本,他正在使用它们;他可能不想在生产应用中使用 sprockets 3 的测试版。
      • 是的,实际上我的 gem 文件中没有明确的链轮。我想我拥有的一颗宝石必须与它绑定。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 2012-04-18
      • 2018-07-07
      • 1970-01-01
      相关资源
      最近更新 更多