title: Mina deploy failure - cannot load such file -- Nokogiri
body: <p>I'm using Mina to deploy a Rail application to a VPS (digital ocean).</p>
  
  <p>When I use <code>mina deploy</code> I keep getting the same error:</p>
  
  <pre><code>rake aborted!
  LoadError: cannot load such file -- nokogiri
  
      C:\Sites\app&gt;mina deploy --trace
      ** Invoke deploy (first_time)
      ** Invoke environment (first_time)
      ** Execute environment
      ** Invoke rvm:use (first_time)
      ** Execute rvm:use
      ** Execute deploy
      ** Invoke git:clone (first_time)
      ** Execute git:clone
      ** Invoke deploy:link_shared_paths (first_time)
      ** Execute deploy:link_shared_paths
      ** Invoke bundle:install (first_time)
      ** Execute bundle:install
      ** Invoke rails:db_migrate (first_time)
      ** Execute rails:db_migrate
      ** Invoke rails:assets_precompile (first_time)
      ** Execute rails:assets_precompile
      ** Invoke deploy:cleanup (first_time)
      ** Execute deploy:cleanup
      user@45.45.45.45's password:
      -----&gt; Using RVM environment 'ruby-2.2.1@default'
      $ rvm use "ruby-2.2.1@default" --create
      Using /usr/local/rvm/gems/ruby-2.2.1
      -----&gt; Creating a temporary build path
      $ touch "deploy.lock"
      $ mkdir -p "./tmp/build-%s2267"
      $ cd "./tmp/build-%s2267"
      -----&gt; Fetching new git commits
      $ (cd "/home/user/app/scm" &amp;&amp; git fetch "git@bitbucket.org:user/app.git" "master:master" --force)
      Enter passphrase for key '/home/user/.ssh/id_rsa':
      -----&gt; Using git branch 'master'
      $ git clone "/home/user/app/scm" . --recursive --branch "master"
      Cloning into '.'...
      done.
      -----&gt; Using this git commit
  
      $ git --no-pager log --format='%%%%aN (%%%%h):%%%%n&gt; %%%%s' -n 1 %aN (%h):%n&gt; %s
      $ rm -rf .git
  
      -----&gt; Symlinking shared paths
      $ mkdir -p "./config"
      $ mkdir -p "."
      $ rm -rf "./config/database.yml"
      $ ln -s "/home/user/app/shared/config/database.yml" "./config/database.yml"
      $ rm -rf "./log"
      $ ln -s "/home/user/app/shared/log" "./log"de
      -----&gt; Installing gem dependencies using Bundler
      $ mkdir -p "/home/user/app/shared/bundle"
      $ mkdir -p "./vendor"
      $ ln -s "/home/user/app/shared/bundle" "./vendor/bundle"
      $ bundle install --without development:test --path "./vendor/bundle" --deployment
      Fetching gem metadata from https://rubygems.org/............
      Fetching version metadata from https://rubygems.org/...
      Fetching dependency metadata from https://rubygems.org/..
      Using rake 10.4.2
      Using i18n 0.7.0
      Using json 1.8.2
      Using minitest 5.6.1
      Using thread_safe 0.3.5
      Using tzinfo 1.2.2
      Using activesupport 4.2.0
      Using builder 3.2.2
      Using erubis 2.7.0
      Using rails-deprecated_sanitizer 1.0.3
      Using rails-dom-testing 1.0.6
      Using loofah 2.0.2
      Using rails-html-sanitizer 1.0.2
      Using actionview 4.2.0
      Using rack 1.6.1
      Using rack-test 0.6.3
      Using actionpack 4.2.0
      Using globalid 0.3.5
      Using activejob 4.2.0
      Using mime-types 2.5
      Using mail 2.6.3
      Using actionmailer 4.2.0
      Using activemerchant 1.47.0
      Using activemodel 4.2.0
      Using arel 6.0.0
      Using activerecord 4.2.0
      Using acts_as_list 0.7.2
      Using addressable 2.3.8
      Using execjs 2.5.2
      Using autoprefixer-rails 5.1.11
      Using awesome_nested_set 3.0.2
      Using sass 3.4.13
      Using bootstrap-sass 3.3.4.1
      Using camertron-eprun 1.1.0
      Using cancancan 1.10.1
      Using bundler 1.8.4
      Using thor 0.19.1
      Using railties 4.2.0
      Using sprockets 3.0.3
      Using sprockets-rails 2.3.0
      Using rails 4.2.0
      Using canonical-rails 0.0.9
      Using carmen 1.0.2
      Using cldr-plurals-runtime-rb 1.0.0
      Using climate_control 0.0.3
      Using cocaine 0.5.7
      Using coffee-script-source 1.8.0
      Using coffee-script 2.4.1
      Using coffee-rails 4.1.0
      Using colorize 0.7.7
      Using css_parser 1.3.6
      Using daemons 1.2.2
      Using polyglot 0.3.5
      Using deface 1.0.1
      Using orm_adapter 0.5.0
      Using responders 2.1.0
      Using warden 1.2.3
      Using devise 3.4.1
      Using devise-encryptable 0.1.2
      Using eventmachine 1.0.7
      Using ffaker 1.32.1
      Using font-awesome-rails 4.3.0.0
      Using friendly_id 5.1.0
      Using friendly_id-globalize 1.0.0.alpha1
      Using globalize 5.0.1
      Using highline 1.6.21
      Using htmlentities 4.3.3
      Using multi_xml 0.5.5
      Using httparty 0.13.3
      Using i18n_data 0.5.1
      Using multi_json 1.11.0
      Using jbuilder 2.2.13
      Using jquery-rails 4.0.3
      Using jquery-ui-rails 5.0.3
      Using kaminari 0.16.3
      Using kaminari-i18n 0.3.2
      Using khipu 1.3.5
      Using open4 1.3.4
      Using mina 0.3.4
      Using money 6.5.1
      Using monetize 1.3.0
      Using paperclip 4.2.1
      Using paranoia 2.1.2
      Using polyamorous 1.2.0
      Using premailer 1.8.4
      Using premailer-rails 1.8.1
      Using rabl 0.9.4.pre1
      Using rails-i18n 4.0.4
      Using ransack 1.4.1
      Using rdoc 4.2.0
      Using tilt 1.4.1
      Using sass-rails 5.0.3
      Using sdoc 0.4.1
      Using select2-rails 3.5.9.1
      Using state_machines 0.2.2
      Using state_machines-activemodel 0.1.2
      Using state_machines-activerecord 0.2.0
      Using stringex 2.5.2
      Using truncate_html 0.9.2
      Using twitter_cldr 3.1.2
      Using spree_core 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-stable
      )
      Using versioncake 2.3.1
      Using spree_api 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-stable)
  
      Using spree_backend 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-sta
      ble)
      Using spree_cmd 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-stable)
  
      Using spree_frontend 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-st
      able)
      Using spree_sample 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-stab
      le)
      Using spree 3.0.2.beta from git://github.com/spree/spree.git (at 3-0-stable)
      Using spree_auth_devise 3.0.0 from git://github.com/spree/spree_auth_devise.git
      (at 3-0-stable)
      Using spree_gateway 3.0.0.beta from git://github.com/spree/spree_gateway.git (at
       3-0-stable)
      Using spree_i18n 3.0.0 from git://github.com/spree/spree_i18n.git (at 3-0-stable
      )
      Using spree_slider 1.2.0 from git://github.com/spree-contrib/spree_slider.git (a
      t master)
      Using spree_static_content 2.3.0 from git://github.com/spree-contrib/spree_stati
      c_content.git (at 3-0-stable)
      Using thin 1.6.3
      Using turbolinks 2.5.3
      Using uglifier 2.7.1
      Bundle complete! 25 Gemfile dependencies, 116 gems now installed.
      Gems in the groups development and test were not installed.
      Bundled gems are installed into ./vendor/bundle.
      -----&gt; Migrating database
      $ RAILS_ENV="production" bundle exec rake db:migrate
      rake aborted!
      LoadError: cannot load such file -- nokogiri
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/loofah-2.0.2/l
      ib/loofah.rb:3:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/loofah-2.0.2/l
      ib/loofah.rb:3:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/rails-html-san
      itizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/rails-html-san
      itizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/sanitize_helper.rb:3:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/sanitize_helper.rb:3:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/text_helper.rb:32:in `&lt;module:TextHelper&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/text_helper.rb:29:in `&lt;module:Helpers&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/text_helper.rb:6:in `&lt;module:ActionView&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/text_helper.rb:4:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_tag_helper.rb:18:in `&lt;module:FormTagHelper&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_tag_helper.rb:14:in `&lt;module:Helpers&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_tag_helper.rb:8:in `&lt;module:ActionView&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_tag_helper.rb:6:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_helper.rb:4:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers/form_helper.rb:4:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers.rb:50:in `&lt;module:Helpers&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers.rb:4:in `&lt;module:ActionView&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/actionview-4.2
      .0/lib/action_view/helpers.rb:3:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/legacy_asset_tag_helper.rb:7:in `&lt;module:LegacyAsset
      TagHelper&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/legacy_asset_tag_helper.rb:6:in `&lt;module:Rails&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/legacy_asset_tag_helper.rb:4:in `&lt;module:Sprockets&gt;'
  
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/legacy_asset_tag_helper.rb:3:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/helper.rb:54:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/helper.rb:54:in `&lt;module:Helper&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/helper.rb:7:in `&lt;module:Rails&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/helper.rb:6:in `&lt;module:Sprockets&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/rails/helper.rb:5:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/railtie.rb:6:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sprockets-rail
      s-2.3.0/lib/sprockets/railtie.rb:6:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass/rails/railtie.rb:3:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass/rails/railtie.rb:3:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass/rails.rb:11:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass/rails.rb:11:in `&lt;top (required)&gt;'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass-rails.rb:1:in `require'
      /home/user/app/tmp/build-%s2267/vendor/bundle/ruby/2.2.0/gems/sass-rails-5.0
      .3/lib/sass-rails.rb:1:in `&lt;top (required)&gt;'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      76:in `require'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      76:in `block (2 levels) in require'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      72:in `each'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      72:in `block in require'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      61:in `each'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/runtime.rb:
      61:in `require'
      /usr/local/rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler.rb:134:in `
      require'
      /home/user/app/tmp/build-%s2267/config/application.rb:7:in `&lt;top (required)&gt;
      '
      /home/user/app/tmp/build-%s2267/Rakefile:4:in `require'
      /home/user/app/tmp/build-%s2267/Rakefile:4:in `&lt;top (required)&gt;'
      (See full trace by running task with --trace)
      ! ERROR: Deploy failed.
      -----&gt; Cleaning up build
      $ rm -rf "./tmp/build-%s2267"
      Unlinking current
      $ rm -f "deploy.lock"
      OK   
      Connection to 45.45.45.45 closed.
  </code></pre>
  
  <p>It seems that all the necessary gems are being installed except for Nokogiri. I'm not sure how to fix this.</p>
  
  <p>This is my Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.2.0'
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 5.0'
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 1.3.0'
  # Use CoffeeScript for .coffee assets and views
  gem 'coffee-rails', '~&gt; 4.1.0'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', platforms: :ruby
  gem 'coffee-script-source', '1.8.0'
  # Use jquery as the JavaScript library
  gem 'jquery-rails'
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 2.0'
  gem 'khipu'
  gem 'mina'
  gem 'nokogiri', '1.6.1'
  # gem 'unicorn'
  gem 'spree_khipu', :path =&gt; '../spree_khipu'
  
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  gem 'spree', github: 'spree/spree', branch: '3-0-stable'
  gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
  gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
  gem 'spree_i18n', :github =&gt; 'spree/spree_i18n', branch: '3-0-stable'
  gem 'spree_slider', github: 'spree-contrib/spree_slider'
  gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: '3-0-stable'
  gem 'bootstrap-sass', '~&gt; 3.3.4'
  
  # Use Capistrano for deployment
  # gem 'capistrano-rails', group: :development
  gem 'thin'
  
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'
  
    # Access an IRB console on exception pages or by using &lt;%= console %&gt; in views
    gem 'web-console', '~&gt; 2.0'
  end
  
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
  
  
  group  :production do
    gem 'pg'
   end
  </code></pre>