3

I'm upgrading development machines and so I'm in the process of getting my new machine up and running with my project from a repo. I install all needed software (Ruby, Devkits, etc), get the base gems installed (bundler, etc) and run bundle install in my project folder, producing this error:

> bundle install
DL is deprecated, please use Fiddle
Fetching gem metadata from http://rubygems.org/.........
Fetching version metadata from http://rubygems.org/...
Fetching dependency metadata from http://rubygems.org/..
Resolving dependencies.....
Using rake 10.4.2
Using i18n 0.7.0
Using multi_json 1.11.0
Using activesupport 3.2.21
Using builder 3.0.4
Using activemodel 3.2.21
Using erubis 2.7.0
Using journey 1.0.4
Using rack 1.4.5
Using rack-cache 1.2
Using rack-test 0.6.3
Using hike 1.2.3
Using tilt 1.4.1
Using sprockets 2.2.3
Using actionpack 3.2.21
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 3.2.21
Using arel 3.0.3
Using tzinfo 0.3.44
Using activerecord 3.2.21
Using activerecord-sqlserver-adapter 3.2.13
Using activeresource 3.2.21
Using authlogic 3.2.0
Using execjs 2.0.2

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb

Gem files will remain installed in C:/Code/vampire_its/ios/.bundle/gems/ruby/2.0.0/gems/json-1.8.2 for inspection.
Results logged to C:/Code/vampire_its/ios/.bundle/gems/ruby/2.0.0/gems/json-1.8.2/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.

I've been researching solutions for a while now and attempted the suggested solution of running gem install json --verbose, which does indeed install the json gem correctly. However, it isn't properly added to my bundle without running bundle install. I even ran bundler install --verbose but that actually failed so I'm having trouble figuring out what's going on. I've actually tried with every single Ruby version I can get my hands on and every one produces the same error so it's starting to look like it's something on my machine, but I have no idea what.

Any help would be appreciated. Additional files/information will be included below

Version Info

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby200/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: C:/Ruby200/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby200/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby200/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gempath" => "C:/Ruby200/lib/ruby/gems/2.0.0"
  - REMOTE SOURCES:
     - https://rubygems.org/

Gemfile

source 'http://rubygems.org'

gem 'rails', '3.2.21'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3', '~>1.3.7'

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'

# Rake 0.9.1 breaks Rails
gem 'rake', '>=0.9.2'

group :development do
  gem 'rspec-rails', '2.5.0'
  gem 'factory_girl', '~> 2.5.0'
  gem 'rails-erd', '~>1.1.0', :require => false
  gem 'ruby_parser', '~>3.1.1', :require => false # seems to be an implicit dependency of rails-erd
  gem 'pry', '~>0.9.12.6'
  gem 'pry-rails', '~>0.2.2'
  gem 'pry-nav', '~>0.2.3'
  gem 'pry-doc', '~>0.5.1'
  gem 'xml-simple', '~> 1.1.4' 
end

gem "paperclip", "~>2.7.0"
gem "rubyzip", "~>0.9.9"

group :test do
  #gem 'capybara', '~> 1.1.4'
  gem 'rspec', '2.5.0'
  gem 'webrat', '0.7.1'
  gem "faker", '1.2.0'
  #gem "factory_girl", '~> 2.5.0'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'execjs', '~>2.0.2'
  gem 'uglifier', '~>1.3.0'
  gem "jquery-rails", '~>3.0.0'
  gem 'jquery-ui-rails'
  gem 'underscore-rails'
  gem "backbone-rails"
end

gem 'authlogic', '~>3.2.0'
gem "declarative_authorization", '~>0.5.6'
gem "sys-filesystem", '1.0.0'
gem "dynamic_form" , '~>1.1.4'
gem 'client_side_validations', '~>3.2.1'
gem "rest-client", '~>1.6.7', :require => "rest_client"
gem "httpclient"
gem 'd3-rails', '~>0.0.5'
gem 'bindata', '~>1.4.5'
gem 'eventmachine', '~>1.0.7', :require => false

if RUBY_PLATFORM =~ /darwin/
  #gem "geotrans", "0.0.1" , :path => '../geotrans/pkg/geotrans-0.0.1-x86_64-darwin-12'
elsif RUBY_PLATFORM =~ /(win|w)32$/
  gem "geotrans", "0.0.2" , :path => '../geotrans/pkg/geotrans-0.0.2-x86-mingw32'
end

gem "unit_conversion", :path => "./local-gems/unit_conversion"

# RGeo for geographic data support
if RUBY_PLATFORM =~ /(win|w)32$/
  gem 'rgeo', "0.3.14" , :path => '../rgeo/pkg/rgeo-0.3.14'
else
  gem 'rgeo', '~>0.3.14'
end

# SQL Server support
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~>3.2.10'

# test coverage
if RUBY_VERSION =~ /1.8/
   gem 'rcov', '~>1.0.0', :require => false, :group => :test
else
   gem 'simplecov', :require => false, :group => :test
end

gem 'delayed_job_active_record', '~>0.3.3'
gem "orderedhash", '~>0.0.6' # binary types uses this

gem "nokogiri", '~> 1.5.9'
gem "js-routes", '~> 0.8.8'
gem "numbers_and_words"
gem "gon", '~> 4.1.1'
gem "bootstrap-sass"
gem 'autoprefixer-rails'

.bundle/config

---
BUNDLE_BIN: .bundle/bin
BUNDLE_PATH: .bundle/gems
BUNDLE_DISABLE_SHARED_GEMS: '1'

C:\Code\vampire_its\ios.bundle\gems\ruby\2.0.0\gems\json-1.8.2\ext\json\ext\generator\gem_make.out

C:/Ruby200/bin/ruby.exe extconf.rb

bundle config

> bundle config
DL is deprecated, please use Fiddle
Settings are listed in order of priority. The top value will be used.
build.json
Set for the current user (C:/Users/Micah Cleveland/.bundle/config): "--version"

bin
Set for your local app (C:/Code/vampire_its/ios/.bundle/config): ".bundle/bin"

path
Set for your local app (C:/Code/vampire_its/ios/.bundle/config): ".bundle/gems"

disable_shared_gems
Set for your local app (C:/Code/vampire_its/ios/.bundle/config): "1"
MCBama
  • 1,432
  • 10
  • 18
  • It's not asking you to install with `--verbose` flag. It's asking you to install with the `-v` flag indicating the specific version of the json gem. Try installing running the full command: `gem install json -v '1.8.2'` – Martin Konecny May 21 '15 at 20:22
  • @MartinKonecny, I researched other people having the same problem and the suggested solution was using the `--verbose` tag. simply using `gem install json -v '1.8.2'` without the verbose flag produced the same error as `bundle install`. Trust me, i tried. – MCBama May 21 '15 at 20:26
  • I'm not saying it will fix your problem. I'm saying it will help us diagnose what's wrong with that specific problematic version. Can you run `--verbose` along with the `-v '1.8.2'` flag – Martin Konecny May 21 '15 at 20:30
  • @MartinKonecny yes, that's how I successfully got it to install at all. the 1.8.2 version of the json gem is actually just the latest version of the gem. I didn't post the "successful" install because it's very, very long due to the `verbose` flag – MCBama May 21 '15 at 20:31
  • 1
    Interesting - so just passing in the additional `--verbose` flag while not removing any others flags fixes the problem? – Martin Konecny May 21 '15 at 20:36
  • @MartinKonecny Right, at least when running `gem install`. `bundle install --verbose` actually doesn't fix the problem but that's because `json` is a dependency, i believe. See why I'm having trouble figuring this out? It's almost like my machine is moving too fast and the stdout printing slows it down enough to work which...seems really illogical – MCBama May 21 '15 at 20:37
  • Maybe post the contents of `C:/Code/vampire_its/ios/.bundle/gems/ruby/2.0.0/gems/json-1.8.2/ext/json/ext/generator/gem_make.out` in your question as well. – Martin Konecny May 21 '15 at 20:38
  • @MartinKonecny It's done. It's literally a single line. Nothing useful. – MCBama May 21 '15 at 20:45
  • Hmm, seems this is a bug in windows version of the `gem` command. Have you tried this: http://stackoverflow.com/a/22982031/276949 ? Or what about running the command prompt as admin user? – Martin Konecny May 21 '15 at 20:49
  • @MartinKonecny yes, I've tried both. That's where I first got my `--verbose` tag idea from actually. Didn't solve the bundler issue. – MCBama May 21 '15 at 20:53

2 Answers2

1

Seems like passing in the --version flag to fix compilation is true bug, as evidenced here.

To mimic this behaviour in bundler we can use bundle config:

You can use bundle config to give bundler the flags to pass to the gem installer every time bundler tries to install a particular gem.

...

After running this command, every time bundler needs to install the mysql gem, it will pass along the flags you specified.

Try running

bundle config build.json --version
bundle install

This should cause bundler to run gem install --verbose json

Community
  • 1
  • 1
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
0

if you run gem install json --verbose -v '1.8.1' you are going to see how the compiler is failing because it is not finding some C modules.

Seems to be that re-installing your current ruby version (with these C headers) might be a possible solution

checking your current ruby version

ruby -v => ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-darwin19]

re-install ruby with C modules (with rbenv)

CC=gcc rbenv install 2.5.8

d1jhoni1b
  • 7,497
  • 1
  • 51
  • 37