Running with Ruby

Tag: Bundler (page 1 of 2)

Bundler warning: this Gemfile contains multiple primary sources

If you see this error:

Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.

It means that you have more than one source in your Gemfile. For example if you use Rails Assets, it might look like this:

source 'https://rubygems.org'
source 'https://rails-assets.org'

# Gems list here...

It is unsafe, because the second source could “inject” a different version of your gems.

To prevent this, you need to declare which gems you want from the second source:

source 'https://rails-assets.org' do
  %w(
    jquery jquery-ujs bootstrap jquery-icheck select2 zeroclipboard
    font-awesome modernizer dropzone seiyria-bootstrap-slider jquery-masonry
    jquery-infinite-scroll imagesloaded markitup livestampjs datetimepicker
    videojs jquery.lazyload magnific-popup
  ).each do |asset_source|
    gem "rails-assets-#{asset_source}"
  end
end

Rails 3.0, Mysql2, Ruby 2.1.0 and undefined symbol: __gxx_personality_v0 – mysql2.so

If you encounter this type of error with your not-migrated/really old Rails 3.0 apps:

/app/.bundle/ruby/2.1.0/extensions/x86-linux/2.1.0/mysql2-0.2.18/mysql2/mysql2.so: 
undefined symbol: __gxx_personality_v0 - /app/.bundle/ruby/2.1.0/extensions/x86-linux/2.1.0/mysql2-0.2.18/mysql2/mysql2.so (LoadError)
  /app/.bundle/ruby/2.1.0/gems/mysql2-0.2.18/lib/mysql2.rb:9:in `require'
  /app/.bundle/ruby/2.1.0/gems/mysql2-0.2.18/lib/mysql2.rb:9:in `<top (required)>'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
  /home/deploy/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
  /app/config/application.rb:3:in `<top (required)>'
  /app/config/environment.rb:2:in `require'
  /app/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'

You need to change your mysql2 gem version. You can’t use mysql2 gem version 0.3.*. Instead you need to use branch 0.2.*:

gem 'rails', '~> 3.0'
gem 'mysql2', "~> 0.2.21"

After that just bundle install and the error should be gone.

Olderposts

Copyright © 2018 Running with Ruby

Theme by Anders NorenUp ↑