部署 使用 mina 部署项目,遇到问题了,求助!:Sprockets::FileNotFound: couldn't find file 'jquery' with type 'application/javascript'

lgor · 2017年08月07日 · 最后由 lgor 回复于 2017年08月08日 · 2640 次阅读

项目是 rails 做服务器,vue 写后台管理调接口。在使用 mina 部署的时候,执行“mina staging deploy”命令的时候,报错:

       Bundle complete! 35 Gemfile dependencies, 89 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into ./vendor/bundle.
       Files /usr/local/ruby/workspace/nextdoor_staging/current/app/assets/config/manifest.js and ./app/assets/config/manifest.js differ
       Files /usr/local/ruby/workspace/nextdoor_staging/current/app/assets/javascripts/application.js and ./app/assets/javascripts/application.js differ
       Files /usr/local/ruby/workspace/nextdoor_staging/current/app/assets/javascripts/cable.js and ./app/assets/javascripts/cable.js differ
       Files /usr/local/ruby/workspace/nextdoor_staging/current/app/assets/stylesheets/application.css and ./app/assets/stylesheets/application.css differ
-----> Precompiling asset files
       ** Invoke assets:precompile (first_time)
       ** Invoke assets:environment (first_time)
       ** Execute assets:environment
       ** Invoke environment (first_time)
       ** Execute environment
       ** Execute assets:precompile
       rake aborted!
       Sprockets::FileNotFound: couldn't find file 'jquery' with type 'application/javascript'
       Checked in these paths: 
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/app/assets/config
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/app/assets/images
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/app/assets/javascripts
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/app/assets/stylesheets
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/assets/javascripts
         /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/assets/stylesheets
         /usr/local/ruby/workspace/nextdoor_staging/shared/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/assets/compiled
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/app/assets/javascripts/application.js:13
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/resolve.rb:65:in `resolve!'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:399:in `resolve'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:207:in `process_require_directive'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:180:in `block in process_directives'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:178:in `each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:178:in `process_directives'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:83:in `_call'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/directive_processor.rb:68:in `call'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:23:in `block in call'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/utils.rb:200:in `dfs'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:24:in `call'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
       /usr/local/ruby/workspace/nextdoor_staging/tmp/build-150207753616923/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `load'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:27:in `run'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli.rb:365:in `exec'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli.rb:22:in `dispatch'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/cli.rb:13:in `start'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/exe/bundle:30:in `block in <top (required)>'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
       /root/.rvm/gems/ruby-2.3.1/gems/bundler-1.15.3/exe/bundle:22:in `<top (required)>'
       /root/.rvm/gems/ruby-2.3.1/bin/bundle:23:in `load'
       /root/.rvm/gems/ruby-2.3.1/bin/bundle:23:in `<main>'
       /root/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
       /root/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK
       Connection to 120.77.232.66 closed.

 !     Run Error

部署配置文件是 staging.rb:

主要是这句错“Sprockets::FileNotFound: couldn't find file 'jquery' with type 'application/javascript'”,因为是用 vue 写的界面,app/assets 下并没有什么 js 文件,只有这些:

不知道为什么还报这个错。而且“Files /usr/local/ruby/workspace/nextdoor_staging/current/app/assets/config/manifest.js and ./app/assets/config/manifest.js differ”说两个文件不一样,但都是同一个 git 的分支 pull 下来的,应该是一样才对。 求各位解答指点一下,O(∩_∩)O 谢谢

不是 mina 的锅 你在服务器上手动执行 RAILS_ENV=production bundle exec assets:precompile 试试看

看上去,可能是没有 jquery-rails,但是 application.js 里面又使用了 jquery。

lgor 关闭了讨论。 08月07日 14:47
lgor 重新开启了讨论。 08月07日 14:47

经过尝试、排查,是我在 Gemfile 里的几个相关的 gem 没有打开,唉,接手一个全新语言写的项目,很多问题磕磕碰碰~

lgn21st 回复

请问,用 mina product deploy 命令部署成功后怎么启动项目呢?

lgor 回复

这个问题取决于你想用什么 web server,是 unicorn/puma 还是 passenger,都有具体的操作方式,这些问题都可以 google 或者本论坛搜索查询。

我整理过一个 mina+puma+nginx+centos7 自启动脚本的笔记,不知道对楼主有没有用。我是新手,很多东西都还在摸索。 CentOS7 使用 mina + github 部署 Rails 项目

9 楼 已删除
samport 回复

谢谢!

lgn21st 回复

嗯嗯,谢谢

lgor 关闭了讨论。 08月08日 14:03
需要 登录 后方可回复, 如果你还没有账号请 注册新账号