Middleman server will not start, regexp has invali

2019-09-02 15:38发布

问题:

I have moved hosting providers and reinstalled ruby and middleman.

When I run bundle exe middleman server I get:

/var/lib/gems/1.8/gems/haml-4.0.4/lib/haml/parser.rb:86: warning: regexp has invalid interval /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman-s3_sync.rb:2:in require': /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman/s3_sync.rb:54: syntax error, unexpected ':', expecting ')' (SyntaxError) @progress_bar ||= ProgressBar.create(total: paths.length) ^ /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman/s3_sync.rb:54: syntax error, unexpected ')', expecting kEND /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman/s3_sync.rb:67: syntax error, unexpected '.', expecting kEND ... .reject { |p| File.directory?(p... ^ /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman/s3_sync.rb:137: syntax error, unexpected $end, expecting kEND from /var/lib/gems/1.8/gems/middleman-s3_sync-3.0.21/lib/middleman-s3_sync.rb:2 from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:inrequire' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in require' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:ineach' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in require' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:ineach' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in require' from /var/lib/gems/1.8/gems/bundler-1.3.5/lib/bundler.rb:132:inrequire' from /var/lib/gems/1.8/gems/middleman-core-3.2.0/lib/middleman-core/load_paths.rb:38:in setup_load_paths' from /var/lib/gems/1.8/gems/middleman-core-3.2.0/bin/middleman:10 from /usr/local/bin/middleman:19:inload' from /usr/local/bin/middleman:19

My Ruby knowledge is very poor, but when I look at the code I do not see a syntax error. I have had a look at the s3_sync git hub code and this part of the code has not changed in some time. I suspect this is an encoding issue, however I am a bit stuck in trying to fix it. Any light you can shed will be very helpful.

Additional info: I have tried on Ruby 1.8 and 1.9.3. And This is on Ubuntu 12.04.

回答1:

The SyntaxError seems to be complaining about this inside Middleman:

ProgressBar.create(total: paths.length)

The /var/lib/gems/1.8/ path indicates that you're using Ruby 1.8.X. But the JavaScript-style Hash notation:

total: paths.length

doesn't work in 1.8, you have to use the :total => paths.length notation there. Looks like you can't use that version of Middleman with 1.8.7, either upgrade to 1.9.3+ or downgrade your Middleman to something that works with older Rubies.