Error building a theme with middleman (can't convert nil into String), /usr/local/bin/middleman:23:in `load'

StackOverflow https://stackoverflow.com/questions/18226020

  •  24-06-2022
  •  | 
  •  

Question

I try to built a theme with ruby (css, js, etc) but I have an error that I've spent hours trying to resolve it and reading docs, but without success.

Here is the error I get when I do a : bundle exec middleman build --verbose

== Request: /pages/forms/forms.html
       error  build/pages/forms/forms.html
can't convert nil into String
/var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/core_ext/string/output_safety.rb:114:in `concat'
/var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/core_ext/string/output_safety.rb:114:in `safe_concat'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-more/core_extensions/default_helpers.rb:63:in `block in content_tag'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-more/core_extensions/default_helpers.rb:63:in `each'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-more/core_extensions/default_helpers.rb:63:in `content_tag'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/tag_helpers.rb:140:in `safe_content_tag'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_helpers.rb:646:in `select_tag'
/home/polylan/Documents/dev/core-admin-release/source/pages/forms/forms.html.erb:60:in `block in singletonclass'
/home/polylan/Documents/dev/core-admin-release/source/pages/forms/forms.html.erb:65530:in `instance_eval'
/home/polylan/Documents/dev/core-admin-release/source/pages/forms/forms.html.erb:65530:in `singletonclass'
/home/polylan/Documents/dev/core-admin-release/source/pages/forms/forms.html.erb:65528:in `__tilt_16623600'
/var/lib/gems/1.9.1/gems/tilt-1.3.7/lib/tilt/template.rb:144:in `call'
/var/lib/gems/1.9.1/gems/tilt-1.3.7/lib/tilt/template.rb:144:in `evaluate'
/var/lib/gems/1.9.1/gems/tilt-1.3.7/lib/tilt/template.rb:77:in `render'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/rendering.rb:273:in `render_individual_file'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/rendering.rb:150:in `render_template'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/sitemap/resource.rb:150:in `block in render'
/var/lib/gems/1.9.1/gems/activesupport-3.2.14/lib/active_support/notifications.rb:125:in `instrument'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/util.rb:60:in `instrument'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/application.rb:196:in `instrument'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/sitemap/resource.rb:16:in `instrument'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/sitemap/resource.rb:121:in `render'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/request.rb:252:in `process_request'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/request.rb:202:in `block in call!'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/request.rb:201:in `catch'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/request.rb:201:in `call!'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/core_extensions/request.rb:187:in `call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-more/extensions/minify_css.rb:48:in `call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lint.rb:49:in `_call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lint.rb:37:in `call'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/mock_session.rb:30:in `request'
/var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/test.rb:230:in `process_request'
/var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/test.rb:57:in `get'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:138:in `render_to_file'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:280:in `block in execute!'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:277:in `each'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:277:in `execute!'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:199:in `invoke!'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/actions.rb:95:in `action'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli/build.rb:64:in `build'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli.rb:77:in `method_missing'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:29:in `run'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:128:in `run'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
/var/lib/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/lib/middleman-core/cli.rb:22:in `start'
/var/lib/gems/1.9.1/gems/middleman-core-3.1.4/bin/middleman:18:in `<top (required)>'
/usr/local/bin/middleman:23:in `load'
/usr/local/bin/middleman:23:in `<main>'

Here is the result of : bundle install

Using i18n (0.6.5) 
Using multi_json (1.7.9) 
Using activesupport (3.2.14) 
Using chunky_png (1.2.8) 
Using coffee-script-source (1.6.3) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using fssm (0.2.10) 
Using sass (3.2.10) 
Using compass (0.12.2) 
Using ffi (1.9.0) 
Using tilt (1.3.7) 
Using haml (4.0.3) 
Using hike (1.2.3) 
Using json (1.7.7) 
Using kramdown (1.1.0) 
Using rb-fsevent (0.9.3) 
Using rb-inotify (0.9.1) 
Using rb-kqueue (0.2.0) 
Using listen (1.2.3) 
Using bundler (1.3.5) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using thor (0.18.1) 
Using middleman-core (3.1.4) 
Using middleman-more (3.1.4) 
Using sprockets (2.10.0) 
Using sprockets-helpers (1.0.1) 
Using sprockets-sass (1.0.1) 
Using middleman-sprockets (3.1.4) 
Using uglifier (2.1.2) 
Using middleman (3.1.4) 
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

My Gemfile

source 'http://rubygems.org'

gem "middleman", "~>3.1.4"
# Live-reloading plugin
gem "middleman-livereload", "~> 3.1.0"
gem 'json', '~> 1.7.7'

gem 'therubyracer'

if RUBY_PLATFORM =~ /linux/i
  gem 'rb-inotify', '~> 0.9'
else
  gem 'rb-inotify'
end

I use : ruby 1.9.1 ruby1.9.1-dev middleman (last version) nodejs therubyracer execjs

UPDATE 1 :

Thanks to j03w comment the error looks like to be indeed to this portion of code in forms.html.erb

<li>
  <label>Dropdown with search:</label>
  <%= select_tag :colors, options: @colorList.shuffle, class: "chzn-select" %>
</li>

<li>
  <label>Dropdown menu:</label>
  <%= select_tag :colors, options: @colorList.shuffle, class: "uniform" %>
</li>

Here is a part of my config.rb where the array is :

@release = false

@colorList = ["Aero blue","Air Force blue (RAF)","Air Force blue (USAF)","Air superiority blue","Alabama Crimson","Alice blue","Alizarin crimson","Alloy orange","Almond","Amaranth","Amazon","Amber",
              "SAE/ECE Amber (color)","American rose","Amethyst","Android Green","Anti-flash white","Antique brass","Antique bronze","Antique fuchsia "]

If you need more information, feel free to ask.

Any help would be very appreciated if you had de the same problem or any idea about that error.

Thanks in advance.

Yann

Was it helpful?

Solution

J03w is right. It looks like it has something to do with the @ variable you're passing to options in the select_tag.

I couldn't figure it out but came up with an alternative that worked fine using a ruby each loop to create the select lists options.

<ul>
    <li>
        <label>Dropdown with search:</label>
        <select name="color-search" id="color-search" class="chzn-select">
            <% @colorList.shuffle.each do |color| %>
                <option value="<%= color %>"><%= color %></option>
            <% end %>
        </select>
    </li>

    <li>
        <label>Dropdown menu:</label>
        <select name="colors" id="colors" class="uniform">
            <% @colorList.shuffle.each do |color| %>
                <option value="<%= color %>"><%= color %></option>
            <% end %>
        </select>
    </li>
</ul>

I'm gonna keep playing around to see if I can figure out your initial issue but hopefully this helps you to move on to other things in the mean time.

UPDATE 1: It looks like middleman doesn't like passing an array to the select_tag's options parameter which is odd because it should work fine. Initially I thought it was the data in the array that was being stored in @colorList but it all checks out.

I even tried simplifying it to the example used in the middleman docs but still got the nil String error. I'm stumped.

Perhaps an issue with the latest version of middleman (I'm using 3.1.4)?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top