ku1ik / rainbow

Ruby gem for colorizing printed text on ANSI terminals
MIT License
813 stars 68 forks source link

Install issues with 2.2.0 #40

Closed eheydrick closed 7 years ago

eheydrick commented 7 years ago

Getting an error installing rainbow 2.2.0.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory: /home/travis/.rvm/gems/ruby-2.3.0/gems/rainbow-2.2.0/ext
/home/travis/.rvm/rubies/ruby-2.3.0/bin/ruby mkrf_conf.rb
current directory: /home/travis/.rvm/gems/ruby-2.3.0/gems/rainbow-2.2.0/ext
/home/travis/.rvm/rubies/ruby-2.3.0/bin/ruby -rubygems
/home/travis/.rvm/gems/ruby-2.3.0/gems/rake-10.5.0/bin/rake
RUBYARCHDIR=/home/travis/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.0
RUBYLIBDIR=/home/travis/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.0
(in /home/travis/.rvm/gems/ruby-2.3.0/gems/rainbow-2.2.0)
fatal: Not a git repository (or any of the parent directories): .git
rake aborted!
LoadError: cannot load such file -- rspec/core/rake_task
/home/travis/.rvm/gems/ruby-2.3.0/gems/rainbow-2.2.0/Rakefile:2:in `<top
(required)>'
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in
/home/travis/.rvm/gems/ruby-2.3.0/gems/rainbow-2.2.0 for inspection.
Results logged to
/home/travis/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.0/gem_make.out
An error occurred while installing rainbow (2.2.0), and Bundler cannot
continue.
Make sure that `gem install rainbow -v '2.2.0'` succeeds before bundling.
denisdefreyne commented 7 years ago

Perhaps related, but I am getting a similar error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.0/ext
/home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby mkrf_conf.rb

current directory:
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.0/ext
/home/travis/.rvm/rubies/ruby-2.4.0/bin/ruby -rubygems
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake
RUBYARCHDIR=/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.0
RUBYLIBDIR=/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.0
(in /home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.0)
rake aborted!
LoadError: cannot load such file -- bundler/gem_tasks
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.0/Rakefile:1:in
`<top (required)>'
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in
`<main>'
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.0 for
inspection.
Results logged to
/home/travis/build/nanoc/nanoc/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.0/gem_make.out

An error occurred while installing rainbow (2.2.0), and Bundler cannot
continue.
Make sure that `gem install rainbow -v '2.2.0'` succeeds before bundling.

This particular error is a LoadError: cannot load such file -- bundler/gem_tasks, though—not the same error as you’re getting.

odcinek commented 7 years ago

Same here, https://github.com/facebook/between-meals/issues/64

tardate commented 7 years ago

merging "2.2.0 failed to build gem native extension on travis-ci" #41 which I closed as a duplicate. Same issue; my notes:

just hit this issue on travis-ci: https://travis-ci.org/benbalter/jekyll-readme-index/builds/187073263 when the latest build pulled 2.2.0; previously it was using 2.1.0

Installing rainbow 2.2.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

As usual, travis tried 3 times and gave up, building under ubuntu. But locally on MacOSX (10.10.5 ruby 2.4.0), the project updated to 2.2.0 and built fine.

See the build log for exhaustive environment details.

Any idea why this platform variance and what it is about 2.2.0 that might have caused this?

denisdefreyne commented 7 years ago

FYI: I worked around this issue in my own project by adding a version constraint: gem 'rainbow', '>= 2.1.0', '< 2.2.0' — will remove this workaround once this issue is resolved!

TrevorBramble commented 7 years ago

Same for Ruby 2.3.3. Linux x86_64.

jasnow commented 7 years ago

Same for Ruby 2.3.3, Mac 10.11.6

mattbrictson commented 7 years ago

FWIW, I believe the problem is that rainbow's ext/mkrf_conf.rb is not written correctly. This file must generate a Rakefile, as illustrated in this example. Rainbow's does not do this.

When Rubygems subsequently runs rake in the ext directory, it can't find the Rakefile it is expecting there and falls back to the root Rakefile, which blows up with all the various errors we are seeing.

jimeh commented 7 years ago

In my case I came across this when trying to install Rubocop (which depends on rainbow) in a fresh Ruby version.

The main issue seems to be this:

LoadError: cannot load such file -- rspec/core/rake_task

It seems that the rspec gem is required to build the native extensions in 2.2.0. I don't know if this effects earlier versions.

Personally I fixed the issue by simply installing the rspec gem first, and then trying to install rubocop again.

ntl commented 7 years ago

I'm seeing this as well. I didn't realize this gem had a native extension. In my failure, it is the rake gem itself that cannot be loaded. This makes sense to me, though, as our build server does not happen to have rake installed.

jimeh commented 7 years ago

I just tried installing rainbow on a fresh Ruby 2.4.0 install, and turns out it requires both bundler and rspec gems to already be installed.

Here's a complete set of commands and output:

$ gem list

*** LOCAL GEMS ***

bigdecimal (default: 1.3.0)
did_you_mean (1.1.0)
io-console (default: 0.4.6)
json (default: 2.0.2)
minitest (5.10.1)
net-telnet (0.1.1)
openssl (default: 2.0.2)
power_assert (0.4.1)
psych (default: 2.2.2)
rake (12.0.0)
rdoc (default: 5.0.0)
test-unit (3.2.3)
xmlrpc (0.2.1)
$ gem install rainbow
Building native extensions.  This could take a while...
ERROR:  Error installing rainbow:
        ERROR: Failed to build gem native extension.

    current directory: /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0/ext
/Users/jimeh/.rbenv/versions/2.4.0/bin/ruby mkrf_conf.rb

current directory: /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0/ext
/Users/jimeh/.rbenv/versions/2.4.0/bin/ruby -rubygems /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0 RUBYLIBDIR=/Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0
(in /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0)
rake aborted!
LoadError: cannot load such file -- bundler/gem_tasks

(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0 for inspection.
Results logged to /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0/gem_make.out
$ gem install bundler
Fetching: bundler-1.13.7.gem (100%)
Successfully installed bundler-1.13.7
Parsing documentation for bundler-1.13.7
Installing ri documentation for bundler-1.13.7
Done installing documentation for bundler after 4 seconds
1 gem installed
$ gem install rainbow
Building native extensions.  This could take a while...
ERROR:  Error installing rainbow:
        ERROR: Failed to build gem native extension.

    current directory: /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0/ext
/Users/jimeh/.rbenv/versions/2.4.0/bin/ruby mkrf_conf.rb

current directory: /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0/ext
/Users/jimeh/.rbenv/versions/2.4.0/bin/ruby -rubygems /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0 RUBYLIBDIR=/Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0
(in /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0)
rake aborted!
LoadError: cannot load such file -- rspec/core/rake_task

(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rainbow-2.2.0 for inspection.
Results logged to /Users/jimeh/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.0/gem_make.out
$ gem install rspec
Fetching: rspec-support-3.5.0.gem (100%)
Successfully installed rspec-support-3.5.0
Fetching: rspec-core-3.5.4.gem (100%)
Successfully installed rspec-core-3.5.4
Fetching: diff-lcs-1.2.5.gem (100%)
Successfully installed diff-lcs-1.2.5
Fetching: rspec-expectations-3.5.0.gem (100%)
Successfully installed rspec-expectations-3.5.0
Fetching: rspec-mocks-3.5.0.gem (100%)
Successfully installed rspec-mocks-3.5.0
Fetching: rspec-3.5.0.gem (100%)
Successfully installed rspec-3.5.0
Parsing documentation for rspec-support-3.5.0
Installing ri documentation for rspec-support-3.5.0
Parsing documentation for rspec-core-3.5.4
Installing ri documentation for rspec-core-3.5.4
Parsing documentation for diff-lcs-1.2.5
Installing ri documentation for diff-lcs-1.2.5
Parsing documentation for rspec-expectations-3.5.0
Installing ri documentation for rspec-expectations-3.5.0
Parsing documentation for rspec-mocks-3.5.0
Installing ri documentation for rspec-mocks-3.5.0
Parsing documentation for rspec-3.5.0
Installing ri documentation for rspec-3.5.0
Done installing documentation for rspec-support, rspec-core, diff-lcs, rspec-expectations, rspec-mocks, rspec after 5 seconds
6 gems installed
$ gem install rainbow
Building native extensions.  This could take a while...
Successfully installed rainbow-2.2.0
Parsing documentation for rainbow-2.2.0
Installing ri documentation for rainbow-2.2.0
Done installing documentation for rainbow after 0 seconds
1 gem installed
ku1ik commented 7 years ago

I have yanked 2.2.0 from rubygems.org.

@olleolleolle prepared a fix in #42. I merged it into master. Can you guys give it a try (using github URL for rainbow in your Gemfiles)? If this does the trick then I'll push 2.2.1 to rubygems.

jasnow commented 7 years ago

Getting "/home/travis/.rvm/rubies/ruby-2.3.3/bin/ruby: No such file or directory -- rspec (LoadError)" in https://travis-ci.org/jasnow/sample_app_3_2

olleolleolle commented 7 years ago

@sickill A related way to try out the "dependency-less" install: make a build target which does "something else", in addition to the existing targets:

matrix:
  include:
    - rvm: 2.2.6
      install: true # This skips 'bundle install'
      script: gem build rainbow && gem install *.gem
ku1ik commented 7 years ago

I've merged #43 to master. Let's see if that solves the issue (/cc @jasnow).

jasnow commented 7 years ago

Added git: line to my Gemfile (using your master branch) (5 repos) and Travis Ci is all green.

ku1ik commented 7 years ago

I have just pushed 2.2.1 to rubygems. Should be a better release than yesterday's ;)

Thanks guys for the reports, and help (:bow: to @olleolleolle & @jasnow).

ku1ik commented 7 years ago

Not sure if related to the problems discussed here but there's still something wrong wrt rake, see #44.

litch commented 7 years ago

FWIW this remains broken for us:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

current directory: /src/packaging/stage/iva-invoicing-790958424/src/installed-packages/ruby/2.3.0/gems/rainbow-2.2.1/ext 
/usr/bin/ruby2.3 mkrf_conf.rb 

current directory: /src/packaging/stage/iva-invoicing-790958424/src/installed-packages/ruby/2.3.0/gems/rainbow-2.2.1/ext 
rake2.3 RUBYARCHDIR=/src/packaging/stage/iva-invoicing-790958424/src/installed-packages/ruby/2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.1 RUBYLIBDIR=/src/packaging/stage/iva-invoicing-790958424/src/installed-packages/ruby/2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.1 
/usr/local/lib/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem rake (>= 0.a) (Gem::GemNotFoundException) 
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:258:in `bin_path' 
from /usr/bin/rake2.3:22:in `<main>' 

rake failed, exit code 1 

Because we do not have rake installed in our (pretty pristine) build environment. It doesn't seem like it should be a necessity for this.

mckern commented 7 years ago

disclaimer: I am not a maintainer -- I just have a vested interest in getting this worked out

rake is part of the default Ruby compilation/installation for Ruby 2.2 and 2.3 (I don't have 2.1 handy to double check). Are folks using builds of Ruby that have not got Rake packaged/distributed with them? FWIW, here's a fresh Ruby 2.2.6 build with no additional gems or modifications:

mckern@flexo tmp.XoXk8F84r4 $ ./bin/gem install rubocop
Fetching: unicode-display_width-1.1.2.gem (100%)
Successfully installed unicode-display_width-1.1.2
Fetching: ruby-progressbar-1.8.1.gem (100%)
Successfully installed ruby-progressbar-1.8.1
Fetching: powerpack-0.1.1.gem (100%)
Successfully installed powerpack-0.1.1
Fetching: ast-2.3.0.gem (100%)
Successfully installed ast-2.3.0
Fetching: parser-2.3.3.1.gem (100%)
Successfully installed parser-2.3.3.1
Fetching: rainbow-2.2.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed rainbow-2.2.1
Fetching: rubocop-0.46.0.gem (100%)
Successfully installed rubocop-0.46.0
7 gems installed
mckern@flexo tmp.XoXk8F84r4 $

I built it as a one-off for this example, using:

./configure \
    --prefix=/var/folders/jg/0fyykqj50wgc48f_6bygnblr0000gn/T/tmp.XoXk8F84r4 \
    --disable-install-doc \
    --with-opt-dir="/opt/local/opt/openssl:/opt/local/opt/readline:/opt/local/opt/libyaml"
sallustfire commented 7 years ago

For what it's worth, I've been following this since the release of 2.2.0 yesterday because it broke rubocop, which was used for a step on our build server, and we had to pin the version < 2.2.0. 2.2.1 fixes the problem we had yesterday, which was identical to the issue first reported in this thread. The issue with rake missing may be a related but different problem.

jasnow commented 7 years ago

Verified on all 11 repos using rainbow gem - all green. Thanks

ku1ik commented 7 years ago

Looks like rake issue is a different thing, closing this one.