Closed Cohen-Carlisle closed 7 years ago
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
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:
ext/mkrf_conf.rb
.gem install rainbow
, Rubygems sees this extension and attempts to "build" it.mkrf_conf
, this triggers execution of Gem::Ext::RakeBuilder.mkrf_conf.rb
and expects it to generate a Rakefile
in the same directory.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.
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).
@sickill Hello! Everything is hard.
RakeBuilder patch for Rubygems: https://github.com/rubygems/rubygems/pull/1819
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..
@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.
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
My bad, I made a new gem environment and I didn't had the rake dependency on my Gemfile. Installing manually rake worked correctly.
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.
@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.
@olleolleolle That worked, thank you! 😄
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?
@sickill I'm not sure. I can build latest rainbow on MRI 2.4 w/ Rubygems 2.6.8 (Mac OS).
@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.
@Cohen-Carlisle Does the rubygems (gem update --system
) fix work for you? Can this issue be closed?
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.
@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?
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.
(Thanks for your help! :heart:)
@olleolleolle Seems to work for me if I add rake
to the Gemfile
and update Rubygems.
@olleolleolle would a rubygems update be expected to solve the missing rake dependency? I could try to test it but I'm pretty constrained for a few reasons:
rainbow
version to ~> 2.1
Ah, I misspoke.
The code which fails for the original poster is the build extension step.
That code has a setting possibility for saying which executable should be used as "rake". The code looks like this:
rake = ENV['rake']
So, if you can set a lowercase environment variable somehow, this feature could perhaps be leveraged?
I'm having this issue, too, and have added gem 'rake'
to my Gemfile and updated ruby gems. The output for bundle -v
is Bundler version 1.14.3
and the output for gem -v
is 2.6.10
. The errors are below:
current directory: /Users/sallyhall/.bundle/gems/rainbow-2.2.1/ext
/Users/sallyhall/.rvm/rubies/ruby-2.3.3/bin/ruby mkrf_conf.rb
Ignoring eventmachine-1.2.0.1 because its extensions are not built. Try: gem
pristine eventmachine --version 1.2.0.1
Ignoring ffi-1.9.14 because its extensions are not built. Try: gem pristine ffi
--version 1.9.14
Ignoring ffi-1.9.10 because its extensions are not built. Try: gem pristine ffi
--version 1.9.10
Ignoring hitimes-1.2.2 because its extensions are not built. Try: gem pristine
hitimes --version 1.2.2
Ignoring mysql2-0.4.4 because its extensions are not built. Try: gem pristine
mysql2 --version 0.4.4
Ignoring mysql2-0.3.21 because its extensions are not built. Try: gem pristine
mysql2 --version 0.3.21
Ignoring nokogiri-1.6.6.2 because its extensions are not built. Try: gem
pristine nokogiri --version 1.6.6.2
Ignoring pg-0.18.3 because its extensions are not built. Try: gem pristine pg
--version 0.18.3
Ignoring puma-3.6.0 because its extensions are not built. Try: gem pristine
puma --version 3.6.0
Ignoring puma-2.13.4 because its extensions are not built. Try: gem pristine
puma --version 2.13.4
Ignoring redcarpet-3.3.3 because its extensions are not built. Try: gem
pristine redcarpet --version 3.3.3
Ignoring therubyracer-0.12.2 because its extensions are not built. Try: gem
pristine therubyracer --version 0.12.2
Ignoring thin-1.7.0 because its extensions are not built. Try: gem pristine
thin --version 1.7.0
current directory: /Users/sallyhall/.bundle/gems/rainbow-2.2.1/ext
/Users/sallyhall/.rvm/rubies/ruby-2.3.3/bin/ruby -rubygems
/Users/sallyhall/.bundle/gems/rake-12.0.0/exe/rake
RUBYARCHDIR=/Users/sallyhall/.bundle/extensions/x86_64-darwin-16/2.3.0/rainbow-2.2.1
RUBYLIBDIR=/Users/sallyhall/.bundle/extensions/x86_64-darwin-16/2.3.0/rainbow-2.2.1
Ignoring eventmachine-1.2.0.1 because its extensions are not built. Try: gem
pristine eventmachine --version 1.2.0.1
Ignoring ffi-1.9.14 because its extensions are not built. Try: gem pristine ffi
--version 1.9.14
Ignoring ffi-1.9.10 because its extensions are not built. Try: gem pristine ffi
--version 1.9.10
Ignoring hitimes-1.2.2 because its extensions are not built. Try: gem pristine
hitimes --version 1.2.2
Ignoring mysql2-0.4.4 because its extensions are not built. Try: gem pristine
mysql2 --version 0.4.4
Ignoring mysql2-0.3.21 because its extensions are not built. Try: gem pristine
mysql2 --version 0.3.21
Ignoring nokogiri-1.6.6.2 because its extensions are not built. Try: gem
pristine nokogiri --version 1.6.6.2
Ignoring pg-0.18.3 because its extensions are not built. Try: gem pristine pg
--version 0.18.3
Ignoring puma-3.6.0 because its extensions are not built. Try: gem pristine
puma --version 3.6.0
Ignoring puma-2.13.4 because its extensions are not built. Try: gem pristine
puma --version 2.13.4
Ignoring redcarpet-3.3.3 because its extensions are not built. Try: gem
pristine redcarpet --version 3.3.3
Ignoring therubyracer-0.12.2 because its extensions are not built. Try: gem
pristine therubyracer --version 0.12.2
Ignoring thin-1.7.0 because its extensions are not built. Try: gem pristine
thin --version 1.7.0
/Users/sallyhall/.rvm/rubies/ruby-2.3.3/bin/ruby: No such file or directory --
/Users/sallyhall/.bundle/gems/rake-12.0.0/exe/rake (LoadError)
rake failed, exit code 1
Gem files will remain installed in /Users/sallyhall/.bundle/gems/rainbow-2.2.1
for inspection.
Results logged to
/Users/sallyhall/.bundle/extensions/x86_64-darwin-16/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.
I have successfully run gem install rainbow -v '2.2.2'
, but bundle install
still fails. Any suggestions?
For people having issues with 2.2.1 I offer the following workaround:
group :workaround do
gem 'rainbow', '~>2.0', '!=2.2.1'
end
I have just released rainbow v2.2.2 with rake as a declared dependency (#58). Thanks for reporting and debugging guys!
@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
@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>'
looks like an undeclared rake dependency