`require': cannot load such file -- bundler (LoadError) - jekyll

I was following up from https://jekyllrb.com/docs/installation/ to install Jekyll and I have made sure that I have Xcode command line tools, gcc and make installed. Version of ruby is 2.1.1 I have installed Jekyll using
gem install jekyll
I got following success message
Done installing documentation for safe_yaml, rouge, forwardable-extended, pathutil, mercenary, liquid, kramdown, ffi, rb-inotify, rb-fsevent, listen, jekyll-watch, sass-listen, sass, jekyll-sass-converter, colorator, public_suffix, addressable, jekyll after 14 seconds
19 gems installed
But when I execute jekyll --version
I got following error
/Users/amar/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)
from /Users/amar/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/amar/.rvm/gems/ruby-2.1.0/gems/jekyll-3.5.2/lib/jekyll/plugin_manager.rb:46:in `require_from_bundler'
from /Users/amar/.rvm/gems/ruby-2.1.0/gems/jekyll-3.5.2/exe/jekyll:9:in `<top (required)>'
from /Users/amar/.rvm/gems/ruby-2.1.0/bin/jekyll:23:in `load'
from /Users/amar/.rvm/gems/ruby-2.1.0/bin/jekyll:23:in `<main>'
from /Users/amar/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/amar/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>

Error was solved by installing new version of bundler again, I had installed it previously as well but there was version issue
gem install bundler
Check your bundler version by
bundler --version
If everything is fine it will show version #
Then again run jekyll --version and everything should go fine

Related

bundler cannot install commonmarker

I'm trying to set up a GitHub Pages repo. Steps I've followed:
Install bundler
$ gem install bundler
Fetching: bundler-2.0.2.gem (100%)
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Installing ri documentation for bundler-2.0.2
Done installing documentation for bundler after 27 seconds
1 gem installed
Good.
Create Gemfile specifying Jekyll at current GH version (3.8.5)
source "https://rubygems.org"
gem "jekyll", "3.8.5"
Run bundle install
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching public_suffix 4.0.1
Installing public_suffix 4.0.1
Fetching addressable 2.7.0
Installing addressable 2.7.0
Using bundler 2.0.2
Fetching colorator 1.1.0
Installing colorator 1.1.0
Using concurrent-ruby 1.1.5
Fetching eventmachine 1.2.7 (x64-mingw32)
Installing eventmachine 1.2.7 (x64-mingw32)
Fetching http_parser.rb 0.6.0
Installing http_parser.rb 0.6.0 with native extensions
Fetching em-websocket 0.5.1
Installing em-websocket 0.5.1
Fetching ffi 1.11.2 (x64-mingw32)
Installing ffi 1.11.2 (x64-mingw32)
Fetching forwardable-extended 2.6.0
Installing forwardable-extended 2.6.0
Using i18n 0.9.5
Fetching rb-fsevent 0.10.3
Installing rb-fsevent 0.10.3
Fetching rb-inotify 0.10.0
Installing rb-inotify 0.10.0
Fetching sass-listen 4.0.0
Installing sass-listen 4.0.0
Fetching sass 3.7.4
Installing sass 3.7.4
Fetching jekyll-sass-converter 1.5.2
Installing jekyll-sass-converter 1.5.2
Fetching listen 3.2.0
Installing listen 3.2.0
Fetching jekyll-watch 2.2.1
Installing jekyll-watch 2.2.1
Fetching kramdown 1.17.0
Installing kramdown 1.17.0
Fetching liquid 4.0.3
Installing liquid 4.0.3
Fetching mercenary 0.3.6
Installing mercenary 0.3.6
Fetching pathutil 0.16.2
Installing pathutil 0.16.2
Fetching rouge 3.13.0
Installing rouge 3.13.0
Fetching safe_yaml 1.0.5
Installing safe_yaml 1.0.5
Fetching jekyll 3.8.5
Installing jekyll 3.8.5
Bundle complete! 1 Gemfile dependency, 25 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from sass:
Ruby Sass has reached end-of-life and should no longer be used.
* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
primary implementation: https://sass-lang.com/install
* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
sassc gem: https://github.com/sass/sassc-ruby#readme
* For more details, please refer to the Sass blog:
https://sass-lang.com/blog/posts/7828841
Some warnings about obsolete packages, but good.
Create new site (Guide step 7)
$ bundler exec jekyll new .
Rewrites Gemfile to
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.8.5"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?
and outputs:
Running bundle install in C:/Projects/coding-for-smarties...
Bundler: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:287:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'minima (~> 2.0) x64-mingw32' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:255:in `each'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:255:in `verify_gemfile_dependencies_are_found!'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:49:in `start'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:22:in `resolve'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/definition.rb:258:in `resolve'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/definition.rb:170:in `specs'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/definition.rb:237:in `specs_for'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/definition.rb:226:in `requested_specs'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:108:in `block in definition_method'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:20:in `setup'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler.rb:107:in `setup'
Bundler: from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-2.0.2/lib/bundler/setup.rb:20:in `<top (required)>'
Bundler: from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Bundler: from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
ERROR Could not find gem 'minima (~> 2.0) x64-mingw32' in any of the gem sources listed in your Gemfile.
Probably not a problem because I want a different theme anyway. So I update it, and I also make the changes suggested in Guide steps 8 & 9.
Try install again
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......................
Using concurrent-ruby 1.1.5
Using i18n 0.9.5
Fetching minitest 5.13.0
Installing minitest 5.13.0
Fetching thread_safe 0.3.6
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.5
Installing tzinfo 1.2.5
Fetching activesupport 4.2.10
Installing activesupport 4.2.10
Fetching public_suffix 2.0.5 (was 4.0.1)
Installing public_suffix 2.0.5 (was 4.0.1)
Using addressable 2.7.0
Using bundler 2.0.2
Fetching coffee-script-source 1.11.1
Installing coffee-script-source 1.11.1
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching coffee-script 2.4.1
Installing coffee-script 2.4.1
Using colorator 1.1.0
Fetching ruby-enum 0.7.2
Installing ruby-enum 0.7.2
Fetching commonmarker 0.17.13
Installing commonmarker 0.17.13 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.13/ext/commonmarker
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20191114-10956-3hyma7.rb extconf.rb
creating Makefile
current directory:
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.13/ext/commonmarker
make "DESTDIR=" clean
current directory:
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.13/ext/commonmarker
make "DESTDIR="
generating commonmarker-x64-mingw32.def
compiling arena.c
compiling autolink.c
compiling blocks.c
compiling buffer.c
compiling cmark.c
compiling cmark_ctype.c
compiling commonmark.c
compiling commonmarker.c
In file included from C:/Ruby24-x64/include/ruby-2.4.0/ruby.h:33,
from commonmarker.h:9,
from commonmarker.c:1:
C:/Ruby24-x64/include/ruby-2.4.0/ruby/ruby.h:631:1: warning: 'const' attribute
on function returning 'void' [-Wattributes]
631 | CONSTFUNC(void rb_secure_update(VALUE));
| ^~~~~~~~~
In file included from C:/Ruby24-x64/include/ruby-2.4.0/ruby/ruby.h:2012,
from C:/Ruby24-x64/include/ruby-2.4.0/ruby.h:33,
from commonmarker.h:9,
from commonmarker.c:1:
C:/Ruby24-x64/include/ruby-2.4.0/ruby/intern.h:257:1: warning: 'const' attribute
on function returning 'void' [-Wattributes]
257 | CONSTFUNC(void rb_error_untrusted(VALUE));
| ^~~~~~~~~
C:/Ruby24-x64/include/ruby-2.4.0/ruby/intern.h:259:1: warning: 'const' attribute
on function returning 'void' [-Wattributes]
259 | CONSTFUNC(void rb_check_trusted(VALUE));
| ^~~~~~~~~
In file included from houdini.h:9,
from commonmarker.c:3:
config.h:8: warning: "HAVE_STDBOOL_H" redefined
8 | #define HAVE_STDBOOL_H
|
In file included from C:/Ruby24-x64/include/ruby-2.4.0/ruby/ruby.h:24,
from C:/Ruby24-x64/include/ruby-2.4.0/ruby.h:33,
from commonmarker.h:9,
from commonmarker.c:1:
C:/Ruby24-x64/include/ruby-2.4.0/x64-mingw32/ruby/config.h:30: note: this is the
location of the previous definition
30 | #define HAVE_STDBOOL_H 1
|
compiling core-extensions.c
compiling ext_scanners.c
compiling footnotes.c
compiling houdini_href_e.c
compiling houdini_html_e.c
compiling houdini_html_u.c
compiling html.c
compiling inlines.c
compiling iterator.c
compiling latex.c
compiling linked_list.c
compiling man.c
compiling map.c
compiling node.c
compiling plaintext.c
compiling plugin.c
compiling references.c
compiling registry.c
compiling render.c
compiling scanners.c
compiling strikethrough.c
compiling syntax_extension.c
compiling table.c
compiling tagfilter.c
compiling utf8.c
compiling xml.c
linking shared-object commonmarker/commonmarker.so
C:/Ruby24-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
strikethrough.o:strikethrough.c:(.text+0x2ba): undefined reference to
`__memset_chk'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:259: commonmarker.so] Error 1
make failed, exit code 2
Gem files will remain installed in
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.13 for inspection.
Results logged to
C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/commonmarker-0.17.13/gem_make.out
An error occurred while installing commonmarker (0.17.13), and Bundler
cannot continue.
Make sure that `gem install commonmarker -v '0.17.13' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
github-pages was resolved to 187, which depends on
jekyll-commonmark-ghpages was resolved to 0.1.5, which depends on
jekyll-commonmark was resolved to 1.3.1, which depends on
commonmarker
ERROR An error occurred while installing commonmarker (0.17.13), and Bundler cannot continue.
And I can't get past this. The best I can do is remove all my gem packages and restart, which just leads me back here.
An alternative would be to "use Jekyll in Windows with Docker" (from James Sturtevant)
That would take advantage of the Docker image jekyll/jekyll (see its README).
export JEKYLL_VERSION=3.8
docker run --rm \
--volume="$PWD:/srv/jekyll" \
-it jekyll/jekyll:$JEKYLL_VERSION \
jekyll build
And you don't have to install ruby or wrestle with missing dependencies.

bundle exec - You have already activated json X, but your Gemfile requires json Y

Trying to execute jekyll on cygwin (x64) on Windows when I get this error in spite of using bundle exec prefix.
Shouldn’t the dependency defined in the Gemfile (i.e. 1.8.6) be activated when executing?
Any thoughts on what is going wrong here? I am totally new to the world of Ruby gems. I have looked at other "You have already activated .. " posts showing similar messages but the answers there didn’t solve my problem.
$ bundle exec jekyll serve
$ bundle exec jekyll serve
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:40:in
`block in setup': You have already activated json 2.0.2, but your Gemfile requires json 1.8.6.
Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
Environment
Cygwin x86_64 installed on Windows 7
RVM installed on Cygwin
$ rvm -v
rvm 1.29.0 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-cygwin]
Gemfile - for the jekyll project
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', group: :jekyll_plugins
gem 'json', '~> 1.8.0'
$ gem environment
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.10
- RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-cygwin]
- INSTALLATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0
- USER INSTALLATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/bin/ruby.exe
- EXECUTABLE DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/bin
- SPEC CACHE DIRECTORY: /cygdrive/c/Users/mochapenguin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-cygwin
- GEM PATHS:
- /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0
- /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/bin
- /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0#global/bin
- /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/bin
- /usr/local/bin
- /usr/bin
- /cygdrive/c/Windows/system32
- /cygdrive/c/Windows
- /cygdrive/c/Windows/System32/Wbem
- /cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
- /cygdrive/c/Program Files/Java/jdk1.8.0_121/bin
..... snip .....
- /cygdrive/c/Users/mochapenguin/AppData/Local/atom/bin
- /usr/lib/lapack
- /cygdrive/c/Users/mochapenguin/.rvm/bin
bundle update
$ bundle update
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using i18n 0.8.1
Using json 1.8.6
Using minitest 5.10.1
Using thread_safe 0.3.6
Using public_suffix 2.0.5
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using colorator 1.1.0
Using ffi 1.9.18
Using multipart-post 2.0.0
Using forwardable-extended 2.6.0
Using gemoji 3.0.0
Using net-dns 0.8.0
Using sass 3.4.23
Using rb-fsevent 0.9.8
Using kramdown 1.13.2
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.11.1
Using safe_yaml 1.0.4
Using mini_portile2 2.1.0
Using jekyll-paginate 1.1.0
Using jekyll-swiss 0.4.0
Using minima 2.0.0
Using unicode-display_width 1.1.3
Using bundler 1.14.6
Using tzinfo 1.2.3
Using addressable 2.5.0
Using coffee-script 2.4.1
Using ethon 0.10.1
Using rb-inotify 0.9.8
Using faraday 0.11.0
Using pathutil 0.14.0
Using jekyll-sass-converter 1.5.0
Using nokogiri 1.7.1
Using terminal-table 1.7.3
Using activesupport 4.2.7
Using jekyll-coffeescript 1.0.1
Using typhoeus 0.8.0
Using listen 3.0.6
Using sawyer 0.8.1
Using html-pipeline 2.5.0
Using jekyll-watch 1.5.0
Using octokit 4.6.2
Using jekyll 3.4.3
Using github-pages-health-check 1.3.3
Using jekyll-gist 1.4.0
Using jekyll-avatar 0.4.2
Using jekyll-default-layout 0.1.4
Using jekyll-feed 0.9.2
Using jekyll-github-metadata 2.3.1
Using jekyll-mentions 1.2.0
Using jekyll-optional-front-matter 0.1.2
Using jekyll-readme-index 0.1.0
Using jekyll-redirect-from 0.12.1
Using jekyll-relative-links 0.4.0
Using jekyll-seo-tag 2.1.0
Using jekyll-sitemap 1.0.0
Using jekyll-theme-architect 0.0.3
Using jekyll-theme-cayman 0.0.3
Using jekyll-theme-dinky 0.0.3
Using jekyll-theme-hacker 0.0.3
Using jekyll-theme-leap-day 0.0.3
Using jekyll-theme-merlot 0.0.3
Using jekyll-theme-midnight 0.0.3
Using jekyll-theme-minimal 0.0.3
Using jekyll-theme-modernist 0.0.3
Using jekyll-theme-primer 0.1.7
Using jekyll-theme-slate 0.0.3
Using jekyll-theme-tactile 0.0.3
Using jekyll-theme-time-machine 0.0.3
Using jekyll-titles-from-headings 0.1.5
Using jemoji 0.8.0
Using github-pages 132
Bundle updated!
bundle exec - Full error message
$ bundle exec jekyll serve
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:40:in `block in setup': You have already activated json 2.0.2, but your Gemfile requires json 1.8.6. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `each'
from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `each'
from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:25:in `map'
from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:25:in `setup'
from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler.rb:100:in `setup'
from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/setup.rb:10:in `<top (required)>'
from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
json gems
$ gem list json
*** LOCAL GEMS ***
json (default: 2.0.2, 1.8.6)
bundle show json
$ bundle show json
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/json-1.8.6
Can't uninstall a default gem
$ gem uninstall json -v2.0.2
ERROR: While executing gem ... (Gem::InstallError)
gem "json" cannot be uninstalled because it is a default gem
UPDATE - 12-Apr-2017
I don't know what the issue is still, but I trimmed down the Gemfile to this and it doesn't fall in a heap. Maybe it somehow works when those particular version dependencies are not enforced.
source 'https://rubygems.org'
# sample suggested [here](https://jekyllrb.com/docs/github-pages/) and in github help
gem 'github-pages', group: :jekyll_plugins
UPDATE - 21-Apr-2017
This issue with bundler and system gems is highlighted at Gem Versioning and Bundler - Doing it right
Bundler's sandbox relies on its ability to be present at the very beginning of the Ruby process, and to therefore have the ability to ensure that the versions of all loaded libraries will reflect the ones listed in the Gemfile.lock. By running a system executable, you are executing Ruby code before Bundler can modify the load path and replace the normal Rubygems loading mechanism, allowing arbitrary unmanaged gems to get loaded into memory. Once that happens, all bets are off.
This is what seems to be happening in this situation.
But, as mentioned above - can't uninstall the system json 2.0.2 gem.
A bit late to the game, but hey, I have a solution! this is how I did it: so besides looking in your standard place where gems are installed, there is one other place where gems can apparently be "defined", and brought into the system. I install stuff using rbenv (I recommend this over RVM), and these are the directories for me:
/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems
/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/specifications/default
In your case, your exact location/s might be different, but you should be able to figure it out. If a gem is in the standard place (/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems), you would be able to 'gem uninstall' without a problem. For the other location, though... tough. To simply prevent the system version from being recognized so that you can use the version from the Gemfile, simply move the json-X.gemspec file away from that second directory (/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/specifications/default above) somewhere else. And that's it!
I had the same problem yesterday. I am not an expert but the following worked for me:
I created a new website with Jekyll using:
$ jekyll new "name_site"
I then copied the new GemFile and GemFile.lock from the new folder to the older (where you have a problem). Then, you run:
$ jekyll serve
in the folder of your current website and it should work. Let me know if it works for you!

Configuring a Project for a Database Ruby on Rails

So I'm new to programing and I'm teaching myself Ruby on Rails to get started. I have mysql running and I've downloaded Ruby ruby 2.3.0 and Rails 3.2.22.2 because these are the versions being used in the video tutorial.
I was generating a controller & view, however when it came to the moment of truth to see if everything worked there were problems. I programmed index.html.erb to say "hello world" in my browser but received this message:
ActiveRecord::ConnectionNotEstablished
I believe this is because it's trying to contact the database. So I started to create the database on mysml, and as I reach the point where I create a schema.rb in the dp folder. Only when I type the command in terminal I get this:
julian$ rake db:schema:dump
rake aborted!
LoadError: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.4. Make sure all dependencies are added to Gemfile.)
/Users/julian/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
Gem::LoadError: can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.4. Make sure all dependencies are added to Gemfile.
/Users/julian/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:schema:dump => environment
(See full trace by running task with --trace)
What do I do? I have been stuck on this for hours, does anyone have some guidance?
Please add gem 'activerecord-mysql2-adapter' to your Gemfile
i think you can uninstall the wrong one
gem uninstall <gem_name>
and then install the correct one
gem install <gem_name>

cannot load such file -- mysql/mysql_api

I am completing the tutorial on Ruby on Rails 3 Essential Training through Lynda.com on Windows 7, and I am in the section on "Databases and Migrations". I am attempting to sync the database I have created in MySQL with my Rails project, however I have been running into an abort message. The instructor asked my class to go through Command Prompt to open up our rails project and perform a Rake to build a "schema.rb" with this code:
rake db:schema:dump
Yet each time I type the code in I have gotten this error message:
C:\Users\User\Documents\simple_cms>rake db:schema:dump
rake aborted!
cannot load such file -- mysql/mysql_api
C:/Users/User/Documents/simple_cms/config/application.rb:7:in `<top (required)>'
C:/Users/User/Documents/simple_cms/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Some solutions I have attempted:
I have installed the binary version of mysql. It was built using MySQL Connector/C version 6.0.2. and I added
libmySQL.dll
to
C:\RailsInstaller\Ruby1.9.3\bin
from dev.mysql.com
I have attempted to download the "mysql2" Gem through Command Prompt with the following result:
C:\Users\User\Documents\simple_cms>gem install mysql2
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while..
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
Help?
Or just instalo mysql2 gem. It Works for me at Wim 10.
Are you trying to access a 64 bit MySQL installation from 32 bit Ruby installation. This seems to be problem with a lot of ppl, even I encountered this when I had a new Win7(64 bit) new machine.
try the solution provided on this blog :-
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

gem update mysql2 failed with rails 3.1.0 and win7 [duplicate]

I have the Ruby version ruby 1.9.2p0 (2010-08-18) [i386-mingw32] installed in Windows7.
and the gem vesion 1.3.7
When i tried to install mysql gem, it is showing Failed to build gem native extension error, why is this? my mysql version is 5.1.36(WampServer)
E:\RubyApps\test_app2>gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
E:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=E:/Ruby192/bin/ruby
E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postp
one'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'
from extconf.rb:9:in `<main>'
Gem files will remain installed in E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
2.3 for inspection.
Results logged to E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.3/ext/mysql2/ge
m_make.out
E:\RubyApps\test_app2>
If you are having this same problem in Linux, basically you just need to install a few libraries first. This worked for me.
> sudo apt-get install libmysql-ruby libmysqlclient-dev
> gem install mysql
source: http://heatware.net/ruby-rails/solved-installing-mysql-gem-extconf-rb-failed-error/
Since this keeps coming up on google as on of the top results, I should point out that this answers is from almost 2 years ago. Here is a more updated answer: How to use "mysql2" gem in Rails 3 application on Windows 7?
According to the developer there is a already a reported bug for it and he is working on parting mysql2 over to Windows. As of now - it's still in the works. Use the older mysql driver for now - or use sqlite for local development.
This is from the googlegroups discussion
Blockquote
Hey Erwann,
There's a ticket on the mysql2 issue tracker for Win32 support already
at http://github.com/brianmario/mysql2/issues#issue/8 . You can follow
it for progress; I'm doing my best to get things working smoothly for
you guys. Hang tight! :)
Just for the record: The problem should be solved!
The mysql2 gem v.0.2.6 is out, having win32 support.
gem install mysql2 worked without problems now.
See: http://github.com/brianmario/mysql2/issues/issue/8#issue/8/comment/479748
it works,
c:> gem install mysql2 -- '--with-mysql-lib="C:\Prog
ram Files\MySQL\MySQL Connector C 6.0.2\lib\opt" --with-mysql-include="C:\Progra
m Files\MySQL\MySQL Connector C 6.0.2\include"'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.6
1 gem installed
Installing ri documentation for mysql2-0.3.6...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.3.6...
Enclosing class/module 'mMysql2' for class Client not known
Note:
I. If there is no lib and include directory in your mysql then install mysql connector c
II. First install DevKit then only you can install mysql2 plugin in windows
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
You can try
gem install mysql2 -v '0.0.00' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Have you installed the DevKit correctly? If doubt, cross check the steps of installation on -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
I was able to install mysql2 gem after following these steps.
Under Cygwin, I had to be sure to install not just libmysqlclient18, but also libmysqlclient-devel. Then "gem install mysql2" went fine.
There is also, of course, a ruby-mysql2 package in Cygwin.
key: the line that says You have to install development tools first.
ref: devkit
use
gem install mysql
for windows, till mysql2 get it right.