Defect #44051
closed
CSV import fails with `Unquoted fields do not allow new line <"\n"> in line 1` on latest trunk on Windows
Added by Yasu Saku 28 days ago.
Updated 21 days ago.
Description
I faced a problem to import a CSV file into Redmine on Windows.
Environment¶
- Redmine version 6.1.2.devel ( revision r24649 )
- Ruby version 3.2.9-p265 (2025-07-24) [x64-mingw-ucrt]
- Rails version 8.1.3
- Environment development
- Database adapter SQLite
Observed behavior¶
Importing a UTF-8 BOM CSV with CRLF line endings fails with the error below:
⚠️The file is not a CSV file or does not match the settings below (Unquoted fields do not allow new line <"\n"> in line 1.)
Expected behavior¶
The CSV should import successfully.
Comparison¶
The same CSV file imports successfully on 6.1.0.stable under the same Ruby/OS (Windows) environment.
Also, the latest trunk works correctly on Debian (Docker) with the same CSV file.
The issue seems to occur only on Windows.
This looks related to CSV row separator or line ending handling.
I suspect a regression around revision r24428.
Minimal reproducible CSV sample¶
Files
Thank you for reporting the issue.
Could you try applying the following change to app/models/import.rb and see whether it resolves the problem?
I do not have a Windows environment available, so I cannot reproduce the issue myself. Please let me know how it goes.
diff --git a/app/models/import.rb b/app/models/import.rb
index 601b44235..42274a39d 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -279,7 +279,7 @@ class Import < ApplicationRecord
wrapper = settings['wrapper'].to_s
csv_options[:quote_char] = wrapper if wrapper.size == 1
- CSV.foreach(filepath, **csv_options) do |row|
+ CSV.foreach(filepath, 'rb', **csv_options) do |row|
yield row if block_given?
end
end
Thank you for the quick response and the suggested fix.
I tested the change on my Windows environment, and the CSV file could be imported successfully without any issues.
The problem appears to be resolved by opening the file in binary mode ("'rb'").
- Related to Defect #41434: CSV import fails on CRLF files when first row has quoted field with newline added
- Status changed from New to Closed
- Resolution set to Fixed
Fixed the issue in r24668, as part of #41434. Thank you for your support.
Also available in: Atom
PDF