rubocop/rubocop · error · RuboCop::ValidationError
configuration for Lint/Syntax cop found in #{smart_loaded_pa
Error message
configuration for Lint/Syntax cop found in #{smart_loaded_path}
It's not possible to disable this cop. What it means
`Lint/Syntax` is a built-in, always-on cop that reports parser errors; it has no tunable parameters and cannot be disabled. The validator merges your `Lint/Syntax` section with the default and raises `ValidationError` if the result differs in any way — even an `Enabled: false` or an `Exclude` list.
Source
Thrown at lib/rubocop/config_validator.rb:163
if suggestions.any?
"Did you mean `#{suggestions.join('`, `')}`?"
else
# Department names can contain slashes, e.g. Chef/Correctness, but there's no support for
# the concept of higher level departments in RuboCop. It's a flat structure. So if the user
# tries to configure a "top level department", we hint that it's the bottom level
# departments that should be configured.
suggestions = departments.select { |department| department.start_with?("#{name}/") }
"#{name} is not a department. Use `#{suggestions.join('`, `')}`." if suggestions.any?
end
end
def validate_syntax_cop
syntax_config = @config['Lint/Syntax']
default_config = ConfigLoader.default_configuration['Lint/Syntax']
return unless syntax_config && default_config.merge(syntax_config) != default_config
raise ValidationError,
"configuration for Lint/Syntax cop found in #{smart_loaded_path}\n" \
'It\'s not possible to disable this cop.'
end
def validate_new_cops_parameter
validate_all_cops_new_cops_parameter
validate_department_new_cops_parameters
end
def validate_all_cops_new_cops_parameter
new_cop_parameter = @config.for_all_cops['NewCops']
return if new_cop_parameter.nil? || NEW_COPS_VALUES.include?(new_cop_parameter)
message = "invalid #{new_cop_parameter} for `NewCops` found in " \
"#{smart_loaded_path}\n" \
"Valid choices are: #{NEW_COPS_VALUES.join(', ')}"
raise ValidationError, messageView on GitHub (pinned to ea712edf2b)
Solutions
- Delete the `Lint/Syntax` section from the config — syntax checking cannot be turned off.
- For files that must not be parsed at all, exclude them globally with `AllCops: Exclude` (the files are then never inspected).
- If specific files legitimately contain non-Ruby content, give them a non-.rb extension or move them outside the include paths.
Example fix
# before (.rubocop.yml)
Lint/Syntax:
Enabled: false
# after — drop the section; if files must be skipped entirely:
AllCops:
Exclude:
- 'fixtures/invalid.rb' Defensive patterns
Strategy: validation
Validate before calling
config = YAML.load_file('.rubocop.yml')
if config.key?('Lint/Syntax')
abort 'Lint/Syntax is not configurable — remove the section; use AllCops: Exclude to skip files'
end Try / catch
begin
RuboCop::CLI.new.run([])
rescue RuboCop::ValidationError => e
raise unless e.message.include?('Lint/Syntax')
puts 'syntax checking is always on; remove the Lint/Syntax section'
exit 1
end Prevention
- Never add keys under Lint/Syntax; it is a protected, always-on cop.
- To keep broken snippets in-repo, exclude their paths via AllCops: Exclude or use non-Ruby extensions.
- Assert in a config linting script that protected sections (Lint/Syntax) are absent.
When it happens
Trigger: Adding `Lint/Syntax: Enabled: false` to silence syntax errors; `Lint/Syntax: Exclude: [vendor/**]` to skip generated or vendored files; any key under `Lint/Syntax` at all besides the identical default.
Common situations: Repos with intentionally invalid Ruby snippets (documentation fixtures, test data) triggering syntax offenses; attempts to exclude generated code from parsing.
Related errors
- Ambiguous cop name `%<name>s` used in %<origin>s needs depar
- Passing a project root directory to `inject_defaults!` is no
- Configuration file not found: #{absolute_path}
- can't inherit configuration from the rubocop gem
- (obsolete configuration found in #{smart_loaded_path}, pleas
AI-assisted analysis of rubocop/rubocop@ea712edf2b (2026-08-21).
Data as JSON: /api/errors/8f6f983d5885bdf4.
Report an issue: GitHub.