Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install issues with 2.2.1 #44

Closed
Cohen-Carlisle opened this issue Dec 28, 2016 · 29 comments
Closed

Install issues with 2.2.1 #44

Cohen-Carlisle opened this issue Dec 28, 2016 · 29 comments

Comments

@Cohen-Carlisle
Copy link

looks like an undeclared rake dependency

> gem install rainbow -v 2.2.1
Fetching: rainbow-2.2.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rainbow:
	ERROR: Failed to build gem native extension.

    /opt/rh/rh-ruby22/root/usr/bin/ruby mkrf_conf.rb

rake RUBYARCHDIR=/home/deployer/.gem/ruby/extensions/x86_64-linux/rainbow-2.2.1 RUBYLIBDIR=/home/deployer/.gem/ruby/extensions/x86_64-linux/rainbow-2.2.1
sh: rake: command not found

rake failed, exit code 127

Gem files will remain installed in /home/deployer/.gem/ruby/gems/rainbow-2.2.1 for inspection.
Results logged to /home/deployer/.gem/ruby/extensions/x86_64-linux/rainbow-2.2.1/gem_make.out
@Cohen-Carlisle
Copy link
Author

Cohen-Carlisle commented Dec 29, 2016

We are using rhel6 with the rh-ruby22 package. I did some digging and apparently to get rake at a system-level we need the the separate rh-ruby22-rubygem-rake-10.4.2-16.el6.noarch.rpm package. Fresh installs of ruby 2.2 from source do successfully rainbow, but since this ruby distro does not include rake, it does not.

Edit: clarify rake at system level with italics text

@mattbrictson
Copy link

Hi, I'm not a contributor, but since Rainbow affects many of my projects via RuboCop, I've been following along and doing some troubleshooting.

To be clear, Rake is not required at runtime to use the rainbow gem; rather it is needed at gem install time only in order to build the gem. To my knowledge there is no way to indicate a "build dependency" in Rubygems. That means Rainbow cannot be installed on systems that lack Rake.

However, to unpack this a bit further: Rainbow is simply using the Rubygems Gem::Ext::Builder system as a hack to execute a post-install step. This step installs some additional gems on the Windows platform. It doesn't need Rake, but Rake is a side-effect of the Gem::Ext::Builder hack.

Documentation on the Builder system is hard to find, but here's is what I've pieced together:

  1. Rainbow's gemspec says it has an extension that is built via ext/mkrf_conf.rb.
  2. During gem install rainbow, Rubygems sees this extension and attempts to "build" it.
  3. Because the file is named mkrf_conf, this triggers execution of Gem::Ext::RakeBuilder.
  4. RakeBuilder runs mkrf_conf.rb and expects it to generate a Rakefile in the same directory.
  5. Rainbow's mkrf_conf.rb doesn't generate a useful Rakefile; it runs some Windows-specific logic to install additional gems, and then generates an empty Rakefile to make Rubygems happy.
  6. RakeBuilder then executes rake on this Rakefile (which is a no-op).

At this final step, the installation process will fail if your Ruby installation lacks the rake executable.

To solve this, Rainbow needs a way to do its Windows post-install step without relying on Gem::Ext::RakeBuilder. Honestly I am not sure something like that exists.

@ku1ik
Copy link
Owner

ku1ik commented Jan 6, 2017

The whole mess with bundler/rake/mkrf_conf in 2.2.0 and 2.2.1 is because these extra gems installed via native extension were needed under Window + Ruby 1.9 for ANSI escape codes working.

We have a new PR #46 that drops Ruby 1.9.3 support (and solves these problems by doing so).

@olleolleolle
Copy link
Collaborator

@sickill Hello! Everything is hard.

RakeBuilder patch for Rubygems: rubygems/rubygems#1819

@chulkilee
Copy link

I'm building a docker image from ruby:2.4.0-alpine with Gemfile, which includes rainbow but not rake. For now I just added rake as dependency..

@olleolleolle
Copy link
Collaborator

olleolleolle commented Jan 17, 2017

@sickill I was told that that PR (now merged) may go out as a backport in a rubygems v2.6.9. (It is not a new feature, so it does not need to wait for a 2.7.0.)

Update: Now, 2.6.9 of Rubygems is out, with that Frozen String Literal fix, so having a gem update --system in the before_install step of your Travis configuration would get you that thing installed.

@waltercool
Copy link

waltercool commented Jan 20, 2017

For me, tries to use 'rake24' command, but I only have 'rake' as command.

Using ruby 2.4, but rake from gem.

Output:

current directory: /home/waltercool/.gem/ruby/2.4.0/gems/rainbow-2.2.1/ext
/usr/bin/ruby24 mkrf_conf.rb

current directory: /home/waltercool/.gem/ruby/2.4.0/gems/rainbow-2.2.1/ext
rake24 RUBYARCHDIR=/home/waltercool/.gem/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.1 RUBYLIBDIR=/home/waltercool/.gem/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.1
sh: rake24: command not found

rake failed, exit code 127

@waltercool
Copy link

My bad, I made a new gem environment and I didn't had the rake dependency on my Gemfile. Installing manually rake worked correctly.

@jodosha
Copy link

jodosha commented Jan 22, 2017

We've got a different error on Travis CI:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    can't modify frozen String
Gem files will remain installed in
/home/travis/build/hanami/helpers/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.1
for inspection.
Results logged to
/home/travis/build/hanami/helpers/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/rainbow-2.2.1/gem_make.out
An error occurred while installing rainbow (2.2.1), and Bundler cannot
continue.
Make sure that `gem install rainbow -v '2.2.1'` succeeds before bundling.
The command "eval bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}" failed. Retrying, 2 of 3.

See https://travis-ci.org/hanami/helpers/jobs/194173482

@olleolleolle
Copy link
Collaborator

@jodosha I added a bit above about the 2.6.9 of Rubygems.

Update: Now, 2.6.9 of Rubygems is out, with that Frozen String Literal fix, so having a gem update --system in the before_install step of your Travis configuration would get you that thing installed.

@jodosha
Copy link

jodosha commented Jan 23, 2017

@olleolleolle That worked, thank you! 😄

@ku1ik
Copy link
Owner

ku1ik commented Jan 23, 2017

Is there something we can do in rainbow to make it work without Rubygems 2.6.9?
In other words, is rainbow gemspec to blame here or is it Ruby 2.4 + Rubygems < 2.6.9 combination that's at fault here?

@jodosha
Copy link

jodosha commented Jan 23, 2017

@sickill I'm not sure. I can build latest rainbow on MRI 2.4 w/ Rubygems 2.6.8 (Mac OS).

@olleolleolle
Copy link
Collaborator

olleolleolle commented Jan 23, 2017

@sickill The error is triggered when using the Rakefile-based gemspec extension. On RG versions < 2.6.9. Oh, and there are versions which are OK, which don't have the "frozen string literal" annotations.

@olleolleolle
Copy link
Collaborator

@Cohen-Carlisle Does the rubygems (gem update --system) fix work for you? Can this issue be closed?

Iristyle added a commit to Iristyle/puppet that referenced this issue Jan 25, 2017
 - Note that AppVeyor doesn't yet have Ruby 2.4, likely because the
   folks who maintain RubyInstaller haven't yet released a Windows
   installer for Ruby 2.4

 - This PR also updates Travis to run `gem update --system` because
   Rubygems 2.6.9 is required to install the Rainbow gem on Ruby 2.4.
   There may be a better solution to this problem - this is a quick
   spike to detect any spec failures.

   ku1ik/rainbow#44
Iristyle added a commit to Iristyle/puppet that referenced this issue Jan 25, 2017
 - Note that AppVeyor doesn't yet have Ruby 2.4, likely because the
   folks who maintain RubyInstaller haven't yet released a Windows
   installer for Ruby 2.4

 - This PR also updates Travis to run `gem update --system` because
   Rubygems 2.6.9 is required to install the Rainbow gem on Ruby 2.4.
   There may be a better solution to this problem - this is a quick
   spike to detect any spec failures.

   ku1ik/rainbow#44
@timrogers
Copy link

I'm still having problems here even after running gem update --system:

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

current directory:
/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.1/ext
/home/ubuntu/.rvm/rubies/ruby-2.3.3/bin/ruby mkrf_conf.rb 

current directory:
/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.1/ext
rake
RUBYARCHDIR=/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.1
RUBYLIBDIR=/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.1
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems.rb:270:in
`find_spec_for_exe': can't find gem rake (>= 0.a) (Gem::GemNotFoundException)
from
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems.rb:298:in
`activate_bin_path'
	from /home/ubuntu/.rvm/rubies/ruby-2.3.3/bin/rake:22:in `<main>'

rake failed, exit code 1

Gem files will remain installed in
/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.1 for inspection.
Results logged to
/home/ubuntu/clippy/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/rainbow-2.2.1/gem_make.out

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

@olleolleolle
Copy link
Collaborator

@timrogers Can you update your dump with notes on which Bundler you use? gem -v and bundle -v are necessary for debug tips.

Do you have gem 'rake' in your Gemfile? What happens if you add that?

@timrogers
Copy link

It's fine if I add gem 'rake' to my Gemfile - should that be needed? If that shouldn't be necessary, then I'm happy to get the Rubygems and Bundler versions too.

gudmundur added a commit to interagent/pliny that referenced this issue Feb 15, 2017
stve added a commit to sferik/twitter-ruby that referenced this issue Feb 15, 2017
This is recommended for the rainbow gem (rubocop dependency)
See: ku1ik/rainbow#44 (comment)
jaredbeck added a commit to binarylogic/authlogic that referenced this issue Feb 19, 2017
@philoserf
Copy link

For people having issues with 2.2.1 I offer the following workaround:

group :workaround do
    gem 'rainbow', '~>2.0', '!=2.2.1'
end

jaymzh pushed a commit to facebook/between-meals that referenced this issue Feb 28, 2017
* Fix ci build systems

Update system ruby rubgems > 2.6.9 so we can install `rainbow` gem.
Require `rake` in our Gemfile. Secondary bandaid for `rainbow` gem.

See: ku1ik/rainbow#44
Fix: #64

* Fix svn.rb empty upstream method
mikehale pushed a commit to mikehale/pliny that referenced this issue Mar 3, 2017
sds added a commit to sds/overcommit that referenced this issue Mar 19, 2017
Newer versions of Ruby ship with a broken version of Rubygems (2.6.8)
when doing parallel installs. Fix this by updating Rubygems to a newer
version (2.6.9 has the fix).

See: ku1ik/rainbow#44
@ku1ik
Copy link
Owner

ku1ik commented Apr 21, 2017

I have just released rainbow v2.2.2 with rake as a declared dependency (#58). Thanks for reporting and debugging guys!

@ku1ik ku1ik closed this as completed Apr 21, 2017
@Drenmi
Copy link

Drenmi commented May 3, 2017

@sickill: Not entirely sure it's related, but I came across this SO question, where the OP seems to have the same issue with 2.2.2.

Building native extensions.  This could take a while...
The system cannot find the path specified.
ERROR:  Error installing rubocop:
    ERROR: Failed to build gem native extension.

current directory: C:/_Programming/Ruby/Installation/RailsInstaller/Ruby2.3.
0/lib/ruby/gems/2.3.0/gems/rainbow-2.2.2/ext
C:/_Programming/Ruby/Installation/RailsInstaller/Ruby2.3.0/bin/ruby.exe mkrf_con
f.rb

rake failed, exit code 1

toy added a commit to toy/image_optim that referenced this issue May 3, 2017
shawnferry pushed a commit to shawnferry/puppet that referenced this issue Jun 30, 2017
 - Note that AppVeyor doesn't yet have Ruby 2.4, likely because the
   folks who maintain RubyInstaller haven't yet released a Windows
   installer for Ruby 2.4

 - This PR also updates Travis to run `gem update --system` because
   Rubygems 2.6.9 is required to install the Rainbow gem on Ruby 2.4.
   There may be a better solution to this problem - this is a quick
   spike to detect any spec failures.

   ku1ik/rainbow#44
@declanvk
Copy link

declanvk commented Jul 24, 2017

@sickill: Still having issues matching what was going on in this thread.
Running bundle install --deployment with rainbow version 2.2.2 as a sub-dependency, gives the following error. rake version 10.3.2 is already specified in the Gemfile, gem -v gives version 2.6.12 and bundle -v gives version 1.15.3

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

    current directory: /<main_directory>/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.2/ext
/<user_directory>/.rbenv/versions/2.4.1/bin/ruby mkrf_conf.rb

current directory: /<main_directory>/vendor/bundle/ruby/2.4.0/gems/rainbow-2.2.2/ext
rake RUBYARCHDIR=/<main_directory>/vendor/bundle/ruby/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.2
RUBYLIBDIR=/<main_directory>/vendor/bundle/ruby/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/rainbow-2.2.2
/<user_directory>/.rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem rake (>= 0.a) (Gem::GemNotFoundException)
	from /<user_directory>/.rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in `activate_bin_path'
	from /<user_directory>/.rbenv/versions/2.4.1/bin/rake:22:in `<main>'

NaomiReeves added a commit to NaomiReeves/between-meals that referenced this issue Aug 22, 2017
No longer need to build for ruby 2.1 and ku1ik/rainbow#44 is now
resolved.
NaomiReeves added a commit to NaomiReeves/between-meals that referenced this issue Aug 22, 2017
ku1ik/rainbow#44 is now resolved so we shouldn't need to call this
directly.
NaomiReeves added a commit to NaomiReeves/between-meals that referenced this issue Aug 22, 2017
ku1ik/rainbow#44 is now resolved so we shouldn't need to call this
directly.
jaymzh pushed a commit to facebook/between-meals that referenced this issue Aug 23, 2017
* Removing pinned version of mixlib-shellout

No longer need to support Ruby 2.1 builds

* Removing explict rake dependency

ku1ik/rainbow#44 is now resolved so we shouldn't need to call this
directly.

* Updating Travis builds

Adding support for Ruby 2.4 and updating to 2.3.4

* Update circle builds to use Ruby 2.3.4
apiology pushed a commit to apiology/pronto that referenced this issue Dec 27, 2019
A bug in Rubgems < 2.6.9 prevents the rainbow gem from being installed. See: ku1ik/rainbow#44
AdamHawkinsa pushed a commit to AdamHawkinsa/pronto that referenced this issue Nov 20, 2023
A bug in Rubgems < 2.6.9 prevents the rainbow gem from being installed. See: ku1ik/rainbow#44
awesomesmallwolf added a commit to awesomesmallwolf/ruby-authlogic that referenced this issue Apr 24, 2024
MegaDev007 added a commit to MegaDev007/overcommit that referenced this issue Aug 3, 2024
Newer versions of Ruby ship with a broken version of Rubygems (2.6.8)
when doing parallel installs. Fix this by updating Rubygems to a newer
version (2.6.9 has the fix).

See: ku1ik/rainbow#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests