- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不得不将我的 rails 版本从 5 更新到 6,在此之前一切正常。
问题只发生在 capistrano...当我运行时 rake assets:precompile
即使使用新版本,一切正常。
这是错误:
deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 warning: parser/current is loading parser/ruby25, which recognizes
01 warning: 2.5.7-compliant syntax, but you are running 2.5.3.
01 warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
yarn install v1.16.0
[1/4] Resolving packages...
⠁
success Already up-to-date.
Done in 0.71s.
01 Warning: you are using an unstable release of Node.js (v11.15.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node
01 Webpacker::Compiler.watched_paths has been deprecated. Set additional_paths in webpacker.yml instead.
01 rake aborted!
01 NoMethodError: undefined method `+' for nil:NilClass
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/configuration.rb:31:in `additional_paths'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/configuration.rb:35:in `additional_paths_globbed'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/compiler.rb:93:in `default_watched_paths'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/compiler.rb:57:in `watched_files_digest'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/compiler.rb:38:in `fresh?'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/compiler.rb:43:in `stale?'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/compiler.rb:22:in `compile'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker/commands.rb:51:in `compile'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker.rb:35:in `compile'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/tasks/webpacker/compile.rake:23:in `block (4 levels) in <top (required)>'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker.rb:28:in `ensure_log_goes_to_stdout'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/tasks/webpacker/compile.rake:22:in `block (3 levels) in <top (required)>'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/webpacker.rb:20:in `with_node_env'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/tasks/webpacker/compile.rake:21:in `block (2 levels) in <top (required)>'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/bundler/gems/webpacker-d099e066931b/lib/tasks/webpacker/compile.rake:14:in `block in enhance_assets_precompile'
01 /web/export-at-ibm/shared/bundle/ruby/2.5.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
01 /home/glbrgit/.rbenv/versions/2.5.3/bin/bundle:23:in `load'
01 /home/glbrgit/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
01 Tasks: TOP => webpacker:compile
01 (See full trace by running task with --trace)
#<Thread:0x00007fec80b805a0@/Users/thiagogs/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/thiagogs/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/thiagogs/.rvm/gems/ruby-2.5.3/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as glbrgit@test-export.w3-969.ibm.com: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: warning: parser/current is loading parser/ruby25, which recognizes
warning: 2.5.7-compliant syntax, but you are running 2.5.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
yarn install v1.16.0
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.71s.
require 'rails'
# Pick the frameworks you want:
require 'active_model/railtie'
require 'active_job/railtie'
# require "active_record/railtie"
# require "active_storage/engine"
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'action_cable/engine'
require 'sprockets/railtie'
# require "rails/test_unit/railtie"
require 'i18n/backend/fallbacks'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
# Webpacker::Compiler.watched_paths << '../app/javascript'
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
module ExportAtIbm
class Application < Rails::Application
I18n.available_locales = %w[en br]
config.i18n.default_locale = :br
config.i18n.fallbacks = [I18n.default_locale]
config.middleware.use I18n::JS::Middleware
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.autoload_paths << "#{Rails.root}/lib"
config.eager_load_paths << "#{Rails.root}/lib"
config.assets.paths << Rails.root.join('app', 'assets', 'font', 'roboto')
config.assets.paths << Rails.root.join('vendor', 'assets', 'img')
config.assets.paths << Rails.root.join('vendor', 'assets', 'mdb-addons')
config.generators do |generator|
generator.stylesheets = false
generator.javascripts = false
generator.helper = false
generator.fixture_replacement :factory_bot, dir: 'spec/support/factory_bot/'
end
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Apipie.configure do |config|
config.validate = false
end
config.assets.precompile << %w[i18n i18n/*]
# Don't generate system test files.
config.generators.system_tests = nil
config.customs = {
integrations: JSON.parse(config_for(:integrations).to_json, symbolize_names: true)
}
end
end
# Server info
server 'test-export.w3-969.ibm.com', user: 'glbrgit', roles: %w[app worker], primary: true
# General configs
set :ssh_options, forward_agent: true, user: 'glbrgit', keys: %w[~/.ssh/id_rsa.pub]
set :pty, true
set :use_sudo, false
set :stage, :staging
set :deploy_via, :remote_cache
set :deploy_to, '/web/export-at-ibm'
set :rbenv_ruby, '2.5.3'
set :branch, 'test-qa'
set :linked_files, %w[config/master.key]
set :linked_dirs, %w[assets/uploads]
append :rbenv_map_bins, 'puma', 'pumactl'
# Puma configs
set :puma_threads, [4, 16]
set :puma_workers, 6
set :puma_bind, 'tcp://0.0.0.0:3007'
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.access.log"
set :puma_error_log, "#{release_path}/log/puma.error.log"
set :puma_worker_timeout, nil
set :puma_init_active_record, false # Change to false when not using ActiveRecord
# Create puma directories
namespace :puma do
desc 'Pre-config and Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
# Deploys tasks
namespace :deploy do
desc 'Make sure local git is in sync with remote.'
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/test-qa`
puts 'WARNING: HEAD is not the same as origin/test-qa'
puts 'Run `git push` to sync changes.'
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Compile static dependencies'
task :compile_assets do
on roles(:app) do
execute "cd #{release_path}/ && RAILS_ENV=staging ~/.rbenv/shims/bundle exec rake assets:svg"
end
end
desc 'Run rake yarn:install'
task :yarn_install do
on roles(:app) do
execute "cd #{release_path} && yarn install --force"
end
end
desc 'Run rake i18n_js_export'
task :i18n_js_export do
on roles(:app) do
execute "cd #{release_path}/ && RAILS_ENV=staging ~/.rbenv/shims/bundle exec rake i18n:js:export"
end
end
before 'compile_assets', 'deploy:i18n_js_export'
before 'compile_assets', 'deploy:yarn_install'
after :finishing, :compile_assets
after :finishing, 'deploy:cleanup'
after :finishing, :restart
end
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: .
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
compile: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
additional_paths:
- /app/javascript
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file
extract_css: true
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .vue
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
- .vue
development:
<<: *default
# Verifies that versions and hashed value of the package contents in the project's package.json
check_yarn_integrity: true
webpack_compile_output: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
mode: development
test:
<<: *default
compile: false
cache_manifest: true
# Compile test packs to a separate directory
public_output_path: packs-test
staging:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: false
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: false
最佳答案
在你的 config/webpacker.yml 中,resolved_paths
已被弃用,应替换为 additional_paths
( https://github.com/rails/webpacker/commit/0adb3dc342addaa00122f9b022bf05606225c39c#diff-04c6e90faac2675aa89e2176d2eec7d8R365 )
我希望这会有所帮助,我遇到了同样的问题,这解决了我的问题。
关于ruby-on-rails - 无方法错误 : undefined method `+' for nil:NilClass/ 'additional_paths' [capistrano+webpacker],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62440434/
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!