1

I am new to Middleman and to Ruby. I have installed rvm first:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
\curl -L https://get.rvm.io | bash -s stable --ruby

I added ~/.rvm/bin in the PATH, then installed Ruby with rvm:

rvm install ruby
rvm --default use ruby-2.2.1

Then I installed Middleman and created a new project:

gem install middleman
cd ~/Documents/Web
middleman new my_project
cd my_project

and I installed middleman-bower:

gem install middleman-bower

I added in Gemfile:

gem 'middleman-bower'

and in config.rb:

activate :bower
sprockets.append_path File.join "#{root}", "bower_components"

Then run:

bundle install

And tryed a test with:

middleman build

Then I get the following error:

/home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/extensions.rb:68:in `register': You must provide a Middleman::Extension or a block that returns a Middleman::Extension (RuntimeError)
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:21:in `<module:Bower>'
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:5:in `<module:Middleman>'
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-bower-1.0.2/lib/middleman/bower.rb:4:in `<top (required)>'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:85:in `require'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:85:in `rescue in block in require'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:68:in `block in require'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `each'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `require'
    from /home/alain/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler.rb:134:in `require'
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/load_paths.rb:33:in `setup_bundler'
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-core-4.1.1/lib/middleman-core/load_paths.rb:15:in `setup_load_paths'
    from /home/alain/.rvm/gems/ruby-2.2.1/gems/middleman-cli-4.1.1/bin/middleman:10:in `<top (required)>'
    from /home/alain/.rvm/gems/ruby-2.2.1/bin/middleman:23:in `load'
    from /home/alain/.rvm/gems/ruby-2.2.1/bin/middleman:23:in `<main>'
    from /home/alain/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
    from /home/alain/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

Google was of no help. What strange is that there is no bower executable. I tryed then:

gem install bower

But it changes nothing, even if I comment the two last lines of my config.rb:

page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
configure :development do
  activate :livereload
end
# add bower support
activate :bower
sprockets.append_path File.join "#{root}", "bower_components"

Any idea please ?

EDIT : If I delete the rvm folder and the middleman project, and redo everything except bower, everything is alright. So my problem looks like how to install bower correctly

EDIT : I should have said it was also my first node.js setup ! The following enables to install bower with the node installer :

apt-get install npm
npm install -g bower

But the problem remains the same !

I have also tryed this wrapping solution, but still no progress:

after_configuration do
  sprockets.append_path File.join root.to_s, "bower_components"
end
lalebarde
  • 1,684
  • 1
  • 21
  • 36

1 Answers1

0

I ran into the same problem, but I am using middleman v4, which does not have support for sprockets. I found that out by reading this: https://github.com/middleman/middleman/issues/890

On the middleman website they also mentioned (https://middlemanapp.com/basics/upgrade-v4/#external-tools) that they removed sprockets.

First I added this sprockets gem version in the Gemfile:

gem "middleman-sprockets", "~> 4.0.0.rc"

Then I added this line of code in my config.rb file.

import_path File.expand_path('bower_components', app.root)

Lastly I ran in terminal:

bundle install

And it worked for me from there.

Should also mentioned that I did not use the "middleman-bower" gem like you did, I install bower manually.

Hope this helps

aljaydavids
  • 306
  • 2
  • 5