gollum: incompatible character encodings: UTF-8 and ASCII-8BIT
I am having the following error, when editing pages via gollum, which were modified with an editor (PHPstorm or Mou) and pushed back into the wiki repo - and there as usually located two levels (folders) below root.
Encoding::CompatibilityError at /edit/my-page
incompatible character encodings: UTF-8 and ASCII-8BIT
file: index.rb location: % line: 176
I’ve looked through several encoding issues I’ve found here. And came to the conclusion, that this is an error with grit (fork from gitlab).
I’ve tried different version of ruby (1.9.3, 2.1.2) and gollum (2.1.0, 2.5.0, 3.0.0) to fix the problem, but the only way (for me) to work around this issue, was modifiying this line to:
tree_contents[k] = "%s %s\0%s" % [tmode, obj.name.force_encoding('ASCII-8BIT'), sha]
Which does not really look right to me.
Is there any way to fix this in gollum or even via config.rb?
Error Stacktrace:
localhost - - [28/Jul/2014:19:31:17 CEST] "GET /javascript/editor/langs/markdown.js?_=1406568677805 HTTP/1.1" 200 11837
http://localhost:4567/edit/intern/orga/my-page -> /javascript/editor/langs/markdown.js?_=1406568677805
Encoding::CompatibilityError - incompatible character encodings: UTF-8 and ASCII-8BIT:
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:176:in `%'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:176:in `block in write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:171:in `each'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:171:in `write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:198:in `block in write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:180:in `each'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:180:in `write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:198:in `block in write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:180:in `each'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:180:in `write_tree'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gitlab-grit-2.6.7/lib/grit/index.rb:123:in `commit'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gollum-lib-3.0.0/lib/gollum-lib/committer.rb:170:in `commit'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/gollum-3.0.0/lib/gollum/app.rb:248:in `block in <class:App>'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
/opt/local/lib/ruby1.9/1.9.1/webrick/httpserver.rb:138:in `service'
/opt/local/lib/ruby1.9/1.9.1/webrick/httpserver.rb:94:in `run'
/opt/local/lib/ruby1.9/1.9.1/webrick/server.rb:191:in `block in start_thread'
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 1
- Comments: 30 (11 by maintainers)
Commits related to this issue
- added manual grit patch, see also https://github.com/gollum/gollum/issues/843 — committed to hrzg/docker-gollum by schmunk42 10 years ago
- Enable rugged as an alternative backend to grit Grit seems to be no longer maintained, and using it with new versions of Ruby causes encoding errors. Rugged is in beta right now, but both rugged and... — committed to winkapp/docker-gollum by nsmith 9 years ago
Using
gollum-rugged_adapterworked for me, it requirescmaketo build:After that, it worked without the error.
@bartkamphorst gitlab-grit?
edit I switched to rugged and now everything works fine with utf-8 file names! This should be the default.
I can confirm that the work-around mentioned by @schmunk42 (edit line 176 in grit/index.rb) is working well. This solved my UTF-8 encoding problem.
Thanks!