ruby-on-rails - 运行 rake Assets 时出错 :precompile?

标签 ruby-on-rails ruby ubuntu

我处于一种无法解决的情况,我必须在没有任何文档且没有太多 ruby​​(或 ruby​​ on rails)经验的情况下在 ubuntu 服务器上部署 ruby​​ one rail 应用程序。
我尝试按照各种论坛/教程中列出的步骤进行操作。我已经在端口 80 上启动了 WEBricks 服务器,但是当我尝试从浏览器访问 Web 应用程序的那一刻,我得到以下不是他的浏览器。

couldn't find file './compiled/admin' under '/home/ubuntu/www/my-app/app/assets/stylesheets' with type 'text/css'

然后有人建议我跑
rake assets:precompile当我运行此命令时,我收到以下错误...
    DEPRECATION WARNING: Currently, Active Record suppresses errors raised within `after_rollback`/`after_commit` callbacks and only print them to the logs. In the next version, these errors will no longer be suppressed. Instead, the errors will propagate normally just like in other Active Record callbacks.

You can opt into the new behavior and remove this warning by setting:

  config.active_record.raise_in_transactional_callbacks = true

 (called from <class:User> at /home/ubuntu/www/my-app/app/models/user.rb:27)
rake aborted!
Sprockets::FileNotFound: couldn't find file './compiled/admin' under '/home/ubuntu/www/my-app/app/assets/stylesheets' with type 'text/css'
/home/ubuntu/www/my-app/app/assets/stylesheets/admin.css:10
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/resolve.rb:64:in `resolve!'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:399:in `resolve'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:207:in `process_require_directive'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:180:in `block in process_directives'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:178:in `each'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:178:in `process_directives'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:83:in `_call'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/directive_processor.rb:68:in `call'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in `block in load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/bundle.rb:23:in `block in call'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/utils.rb:183:in `dfs'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/bundle.rb:24:in `call'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in `block in load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `load'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:63:in `find_asset'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:70:in `find_all_linked_assets'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:130:in `block in find'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:129:in `each'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:129:in `find'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:162:in `compile'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-3.2.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/ubuntu/.rvm/gems/ruby-2.3.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

任何帮助都感激不尽。如果您希望我提供任何其他信息,请询问。

以下是app/assets/stylesheets/admin.css文件
/*
 * Admin stylesheets
 *
 *= require select2
 *= require select2-bootstrap
 *= require_tree ./plugins
 *= require_tree ./fonts
 *
 * Pull compiled from /app/assets/stylesheets/compiled
 *= require ./compiled/admin
 *
 */

Gemfile 看起来像这样。
source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0.3'
gem 'less-rails', '~> 2.7.0'
gem 'therubyracer'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'sqlite3', group: :development
gem 'pg'

#bootstrap components
gem 'bootstrap-datepicker-rails'
gem "select2-rails"

#images upload
gem "paperclip", "~> 4.2"
gem 'aws-sdk', '~> 1.6'

group :development do
  gem 'capistrano', '~> 2'
  gem 'spring'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'pry'
  gem 'pry-rails'
  gem 'awesome_print' # https://github.com/michaeldv/awesome_print
end

gem 'rails_12factor', group: [:production, :staging]

#user managment
gem 'devise'
gem 'cancancan', '~> 1.10'
gem 'recaptcha', require: 'recaptcha/rails'
#tracking user data
gem 'classy_enum'

#pagination
gem 'kaminari'

#api serialization
gem 'active_model_serializers'
# To use Jbuilder templates for JSON
gem 'jbuilder'

#dropbox
gem "dropbox-api"

#sidekiq jobs
gem 'sidekiq'
gem 'sidekiq-status'
gem 'sinatra', :require => nil

#for the folders hierarchy tree
gem 'closure_tree'

# PDFs
gem 'doc_raptor'

# Excel Parsing
gem 'roo'

# Emails
gem 'sendgrid'

# auto increment numbers
gem 'protokoll'

# State machine
gem 'aasm'

#elastic search
gem 'elasticsearch-model', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'
gem 'elasticsearch-rails', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'

gem 'rubyzip'

gem 'exception_notification', group: [:production, :staging], github: 'joshco/exception_notification'

gem 'spreadsheet'

应用文件夹中的文件列表
drwxrwxr-x 11 ubuntu ubuntu 4096 Apr  1 08:03 app
drwxrwxr-x  2 ubuntu ubuntu 4096 Apr  1 08:03 bin
drwxrwxr-x  3 ubuntu ubuntu 4096 Apr  1 08:03 client
drwxrwxr-x  5 ubuntu ubuntu 4096 Apr  5 22:08 config
-rw-rw-r--  1 ubuntu ubuntu  153 Apr  1 08:03 config.ru
drwxrwxr-x  4 ubuntu ubuntu 4096 Apr  1 08:03 db
-rw-rw-r--  1 ubuntu ubuntu 1570 Apr  1 08:03 Gemfile
-rw-rw-r--  1 ubuntu ubuntu 9072 Apr  1 08:03 Gemfile.lock
drwxrwxr-x  5 ubuntu ubuntu 4096 Apr  1 08:03 gulp
-rw-rw-r--  1 ubuntu ubuntu  557 Apr  1 08:03 gulpfile.js
drwxrwxr-x  6 ubuntu ubuntu 4096 Apr  1 08:03 lib
drwxrwxr-x  2 ubuntu ubuntu 4096 Apr  6 13:48 log
-rw-rw-r--  1 ubuntu ubuntu 1393 Apr  1 08:03 package.json
-rw-rw-r--  1 ubuntu ubuntu  146 Apr  1 08:03 Procfile
-rw-rw-r--  1 ubuntu ubuntu  143 Apr  1 08:03 Procfile.example
drwxrwxr-x  2 ubuntu ubuntu 4096 Apr  1 08:03 public
-rw-rw-r--  1 ubuntu ubuntu  249 Apr  1 08:03 Rakefile
-rw-rw-r--  1 ubuntu ubuntu 7908 Apr  1 08:03 README.md
drwxrwxr-x  8 ubuntu ubuntu 4096 Apr  1 08:03 test
drwxrwxr-x  6 ubuntu ubuntu 4096 Apr  5 15:14 tmp
drwxrwxr-x  3 ubuntu ubuntu 4096 Apr  1 08:03 vendor
-rw-rw-r--  1 ubuntu ubuntu   64 Apr  1 08:03 webpack.config.js

最佳答案

您的问题是您需要生成将进入此 stylesheets/compiled 的文件文件夹。
两种选择:

  • 了解如何生成它们(如果有关于 bower、grunt 等的文件,请检查项目的根目录。如果有,我需要启动这些文件以实际生成文件)并在 Assets 之前添加相应的部署规则编译或提交结果。
  • 从您的 admin.css 中删除此行文件:*= require ./compiled/admin
  • 关于ruby-on-rails - 运行 rake Assets 时出错 :precompile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36476146/

    相关文章:

    ruby-on-rails - 使用现有软件组件的行为驱动开发

    ruby-on-rails - Rails Controller 继承

    ruby - #!/usr/bin/env ruby​​ 在 cron 中找不到

    ruby - Google Code Jam 2010 大型数据集提交时间过长

    linux - 从本地网络访问在 WSL(Linux 的 Windows 子系统)上运行的 Web 服务器

    javascript - 在 Rails 的 Gmaps 中默认打开 infoWindow

    ruby - 需要模块内的文件?

    shell - -su : syntax error near unexpected token '('

    ubuntu - 如何将 Wii 平衡板与 Ubuntu PC 永久配对?

    ruby-on-rails - 使用 google drive API 将 docx 导出为压缩的 html