SwiftLint
SwiftLint copied to clipboard
Swift Package Manager Plugin `SwiftLint Configuration Error: Unable to cache remote config`
New Issue Checklist
- [x] Updated SwiftLint to the latest version
- [x] I searched for existing GitHub issues
Describe the bug
When I try to use SwiftLint SPM plugin with my Package.swift project, load local non-nested configure is fine, but when I add parent_config, it seems got write permission issue when resolve the remote url
if I'm not wrong it hit here, because when running spm build command can't caching to rootDir as the default configure.
Complete output when running SwiftLint, including the stack trace and command used
/usr/bin/sandbox-exec -p "(version 1)
(deny default)
(import \"system.sb\")
(allow file-read*)
(allow process*)
(allow file-write*
(subpath \"/private/tmp\")
(subpath \"/private/var/folders/8c/kg72g5051tvcx9yzc4_7qh180000gn/T\")
)
(deny file-write*
(subpath \"/Users/user007/Documents/user007/CommonModuleLib\")
)
(allow file-write*
(subpath \"/Users/user007/Library/Developer/Xcode/DerivedDaTM/CommonModuleLib-fpzeyejjipbikmaamsqhxtbqyfph/SourcePackages/plugins/CommonModuleLib.output/CommonModuleLib/SwiftLintPlugin\")
)
" /Users/user007/Library/Developer/Xcode/DerivedDaTM/CommonModuleLib-fpzeyejjipbikmaamsqhxtbqyfph/SourcePackages/artifacts/swiftlint/SwiftLintBinary.artifactbundle/swiftlint-0.50.3-macos/bin/swiftlint lint --quiet --cache-path /Users/user007/Library/Developer/Xcode/DerivedDaTM/CommonModuleLib-fpzeyejjipbikmaamsqhxtbqyfph/SourcePackages/plugins/CommonModuleLib.output/CommonModuleLib/SwiftLintPlugin --config /Users/user007/Documents/user007/CommonModuleLib/.swiftlint.yml /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Cache/TMTemplate.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Cache/TMWebViewPool.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Cache/TMWebviewCache.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Cache/TMWebviewCollection.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Models/AnyDecodable.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Models/TMElementFrame.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Models/TMJavascriptMessage.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Plugins/TMCheckCompatibilityPlugin/TMCheckCompatibilityPlugin.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Plugins/TMHeightObserverPlugin/TMHeightObserverPlugin.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Plugins/TMLifeCyclePlugin/TMLifeCyclePlugin.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Plugins/TMLogPlugin/TMLogPlugin.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Protocols/CommonModuleLibDelegate.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Protocols/CommonModuleLibPluginProtocol.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/Protocols/CommonModuleLibTemplate.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/TMEventHandler.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/TMMessageParser.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/TMURLSchemeHandler.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/BundleExtension.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/CodableTransform.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/LRUCache.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/StringExtension.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/TMConsTMnts.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/TMError.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/TMMapper.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibHelpers/TMNotificationNames.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibViewController+Helper.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibViewController+TMWebViewDelegate.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/CommonModuleLibViewController.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/STMteOperation/AsyncOperation.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/STMteOperation/CommonModuleLibOperation.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/TMSTMteHistory.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/TMWebView.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/CommonModuleLibSTMte.swift /Users/user007/Documents/user007/CommonModuleLib/Sources/CommonModuleLib/WebView/CommonModuleLibSTMteSync.swift
error: SwiftLint Configuration Error: Unable to cache remote config from "http://dest/.parent_swiftlint.yml". Also didn't found cached version to fallback to.
Could not read configuration: file Configuration.swift, line 241
Environment
- SwiftLint version (run
swiftlint versionto be sure)? 0.50.3 - Installation method used (Homebrew, CocoaPods, building from source, etc)? SPM, work with Swift Package Manager Plug-in
- Paste your configuration file:
parent_config: http://localhost:8000/.parent_swiftlint.yml
remote_timeout: 10
included:
- Sources
excluded:
- Tests
- Demo
- .build
line_length:
warning: 500
error: 1000
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
function_body_length:
warning: 300
error: 500
function_parameter_count:
warning: 6
error: 8
type_body_length:
warning: 300
error: 500
file_length:
warning: 1000
error: 1500
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 25
...
- Are you using nested configurations? If so, paste their relative paths and respective contents.
disabled_rules:
- trailing_whitespace
- multiple_closures_with_trailing_closure
- todo
- convenience_type
- for_where
- force_unwrapping
- large_tuple
- force_cast
- force_try
- nesting
opt_in_rules:
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- explicit_init
- fatal_error_message
- file_name_no_space
- first_where
- last_where
- flatmap_over_map_reduce
- legacy_multiple
- legacy_random
- let_var_whitespace
- literal_expression_end_indentation
- multiline_arguments
- multiline_function_chains
- multiline_parameters
- operator_usage_whitespace
- prefer_self_type_over_type_of_self
- prefer_zero_over_explicit_init
- reduce_into
- sorted_first_last
- yoda_condition
excluded:
- ${PWD}/Carthage
- ${PWD}/Pods
- ${PWD}/SwiftLint/Common/3rdPartyLib
- Carthage
- Pods
- SwiftLint/Common/3rdPartyLib
line_length:
warning: 150
error: 200
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
function_body_length:
warning: 300
error: 500
function_parameter_count:
warning: 6
error: 8
type_body_length:
warning: 300
error: 500
file_length:
warning: 1000
error: 1500
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 25
identifier_name:
excluded:
- id
- ad
- lhs
- rhs
- id
- ad
- zb
- sm
- wb
- vc
- vm
- zh
- x
- y
- i
- j
- k
- x1
- y1
allowed_symbols: ["_"]
attributes:
always_on_same_line: ["@discardableResult", "@objc", "@IBAction", "@IBDesignable", "@IBInspectable"]
reporter: "xcode"
- Which Xcode version are you using (check
xcodebuild -version)? Version 14.2 (14C18) - Do you have a sample that shows the issue? Run
echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rulesto quickly test if your example is really demonstrating the issue. No, the issue is not related to rule itself, it related to load configratiion
Swift plugins aren't allowed to make network calls for security reasons. Remote configuration isn't currently possible for plugins because of this.
Worth mentioning that I have built a BuildToolPlugin which can perform network request through a shell script:
.prebuildCommand(
displayName: "Download Fonts",
executable: context.package.directory.appending("download_fonts.sh"),
arguments: [outputDirectory],
outputFilesDirectory: outputDirectory
https://github.com/apple/swift-evolution/blob/main/proposals/0303-swiftpm-extensible-build-tools.md#security
Might also add that although when building using Xcode I get the same error as @atom2ueki.
When executing using xcodebuild, my remote config is downloaded and placed in the cache:
Granted the build doesn't succeed:
❌ error: YML Parsing Error: 39:20428: error: scanner: mapping values are not allowed in this context:
Just thought it worth mentioning.
I just ran into this issue again, and it looks like as of SwiftPM 5.9 a plugin can add a permission to allow network connections: https://developer.apple.com/documentation/packagedescription/pluginpermission/allownetworkconnections(scope:reason:)
I just ran into this issue again, and it looks like as of SwiftPM 5.9 a plugin can add a permission to allow network connections: https://developer.apple.com/documentation/packagedescription/pluginpermission/allownetworkconnections(scope:reason:)
This permission can only be added to Command Plugins. This issue is about Build Tool Plugins though.