Cannot install uchardet gem on Mac OS catalina - ruby-on-rails

Recently I got the following errors when I tried to install the uchardet GEM in MacOS catalina,Even I specific the ICU version and lib, it still doesn't work, anyone have ideas?
Installing uchardet 0.2.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/xxx/.rvm/gems/ruby-2.6.4/gems/uchardet-0.2.0/ext
/Users/xxx/.rvm/rubies/ruby-2.6.4/bin/ruby -I /Users/xxx/.rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200420-38494-q9y0cf.rb extconf.rb
Could not find ICU libraries and/or development tools. Try installing "icu-devtools" or "icu" package.
*** 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
--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=/Users/xxx/.rvm/rubies/ruby-2.6.4/bin/$(RUBY_BASE_NAME)
extconf failed, exit code 1
Gem files will remain installed in /Users/xxx/.rvm/gems/ruby-2.6.4/gems/uchardet-0.2.0 for inspection.
Results logged to /Users/xxx/.rvm/gems/ruby-2.6.4/extensions/x86_64-darwin-19/2.6.0/uchardet-0.2.0/gem_make.out

I was able to reproduce this on my mac:
I fixed this error by re-installing and re-linking icu4c
brew install icu4c
brew link icu4c --force # if it shows you an error and tells you to add the path manually add them
restarted my terminal then re-installed the gem (i also tried this)
you will know it's working when you have which icu-config working https://github.com/dmgk/uchardet/blob/506105c5322fe3cde7ce3e2b2868f875b9b57230/ext/extconf.rb#L3-L6
however now i have another error uchardet.c:2:10: fatal error: 'unicode/ucsdet.h' file not found i do think the gems needs better configuration around this

Related

Unable to install Ruby 3.2.0 with Rbenv -- Missing Pysch gem

I'm currently trying to install Ruby 3.2.0 with Rbenv and I'm getting this error every time.
BUILD FAILED (Ubuntu 22.04 using ruby-build 20230202)
Inspect or clean up the working tree at /tmp/ruby-build.20230202161804.1244.1gO1Ch
Results logged to /tmp/ruby-build.20230202161804.1244.log
Last 10 log lines:
Fix the problems, then remove these directories and try again if you want.
make[1]: Leaving directory '/tmp/ruby-build.20230202161804.1244.1gO1Ch/ruby-3.2.0'
Generating RDoc documentation
/tmp/ruby-build.20230202161804.1244.1gO1Ch/ruby-3.2.0/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby. uh-oh! RDoc had a problem:
cannot load such file -- psych
run with --debug for full backtrace
make: *** [uncommon.mk:598: rdoc] Error 1
It seems this gem PSYCH is missing, but when I run
gem install psych
I get this other message.
Building native extensions. This could take a while...
ERROR: Error installing psych:
ERROR: Failed to build gem native extension.
current directory: /root/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.2/ext/psych
/root/.rbenv/versions/3.1.3/bin/ruby -I /root/.rbenv/versions/3.1.3/lib/ruby/3.1.0 extconf.rb
checking for yaml.h... no
yaml.h not found
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=/root/.rbenv/versions/3.1.3/bin/$(RUBY_BASE_NAME)
--with-libyaml-source-dir
--without-libyaml-source-dir
--with-yaml-0.1-dir
--without-yaml-0.1-dir
--with-yaml-0.1-include
--without-yaml-0.1-include=${yaml-0.1-dir}/include
--with-yaml-0.1-lib
--without-yaml-0.1-lib=${yaml-0.1-dir}/lib
--with-yaml-0.1-config
--without-yaml-0.1-config
--with-pkg-config
--without-pkg-config
--with-libyaml-dir
--with-libyaml-include
--without-libyaml-include=${libyaml-dir}/include
--with-libyaml-lib
--without-libyaml-lib=${libyaml-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/root/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/psych-5.0.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /root/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/psych-5.0.2 for inspection.
Results logged to /root/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/psych-5.0.2/gem_make.out
Any help is super appreciated! Thanks

ERROR: Failed to build gem native extension. potracelib.h not found with M1 chip

I'm trying to install a Rails 5 app in my Macbook Air with M1 chip. This app is using a gem called potracer.
After doing $ bundle install I get the error:
Installing potracer 1.1.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4/ext/potracer
/Users/user/.rvm/rubies/ruby-2.7.2/bin/ruby -I /Users/user/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0 -r ./siteconf20211025-1533-nnxnj9.rb extconf.rb
checking for potracelib.h... no
potracelib.h not found
*** 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
--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=/Users/user/.rvm/rubies/ruby-2.7.2/bin/$(RUBY_BASE_NAME)
--with-potrace-dir
--without-potrace-dir
--with-potrace-include
--without-potrace-include=${potrace-dir}/include
--with-potrace-lib
--without-potrace-lib=${potrace-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.7.2/gems/potracer-1.1.4 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.7.2/extensions/arm64-darwin-20/2.7.0/potracer-1.1.4/gem_make.out
An error occurred while installing potracer (1.1.4), and Bundler cannot continue.
Make sure that `gem install potracer -v '1.1.4' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
potracer
I had other issues installing other rails app with the M1 chip but I found workarounds but not in this case.
Ideas on how to solved this?
You have to reinstall potrace loccaly before. The installation seems to be incomplete.
you would need the library/headers installed. Depending on your platform it would be something like libpotrace and libpitrace-dev.
You would install them via homebrew, apt, dnf, etc.
The potrace execution will abort unless you get the potrace.h locally
abort potracelib.h not found' unless find_header('potracelib.h')
require 'mkmf'
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
LIBDIR = RbConfig::CONFIG['libdir']
INCLUDEDIR = RbConfig::CONFIG['includedir']
HEADER_DIRS = ['/opt/local/include', '/usr/local/include', INCLUDEDIR,
'/usr/include']
LIB_DIRS = ['/opt/local/lib', '/usr/local/lib', LIBDIR, '/usr/lib']
dir_config('potrace', HEADER_DIRS, LIB_DIRS)
abort 'potracelib.h not found' unless find_header('potracelib.h')
abort 'lib potrace not found' unless find_library('potrace', 'potrace_version')
create_header
create_makefile('potracer/potracer')
Source: https://github.com/kennyp/potracer/blob/b67d3ff6a1ae672ccc6701fa5245fa532b461ef3/ext/potracer/extconf.rb

bzip2-ruby Windows Install

I'm attempted to install the bzip2-ruby gem on Windows 7 x64. Now I don't know if this gem even works on 64-bit Windows. I did install bzip2 which got installed to C:\Program Files (x86)\GnuWin32.
When I go to install, the run the following command:
gem install bzip2-ruby -- --with-bz2-dir="C:\Program Files (x86)\GnuWin32\"
When that runs I get the following output:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
*** 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=C:/Ruby193/bin/ruby
--with-bz2-dir
--with-bz2-include
--without-bz2-include=${bz2-dir}/include
--with-bz2-lib
--without-bz2-lib=${bz2-dir}/lib
--with-bz2lib
--without-bz2lib
ERROR: Error installing bzip2-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb --with-bz2-dir=C:\Program Files (x86)\GnuWin32"
checking for bzlib.h... no
checking for BZ2_bzWriteOpen() in -lbz2... no
libbz2 not found, maybe try manually specifying --with-bz2-dir to find it?
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/bzip2-ruby-0.2.7 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/bzip2-ruby-0.2.7/ext/gem_make.out
I can verify that the libbz2.a, libbz2.def, and the libbz2.dll.a files exist in the lib folder at the path above.
Am I just missing an extra option when running the command to specify the lib folder?
Thanks!
For GCC (the compiler bundled in RubyInstaller DevKit) to properly work, you need to use path without spaces.
The option to extconf that you provided has a path with spaces. Please relocate the lib, include and bin folders from bzip2 into a directory without spaces and try again.
Also, you need to have both headers (found in include directory) and the import library (found in lib directory) for extension compilation to work.
Hope that helps.

Installing libv8 for ree on Mountain Lion fails

I've been trying to find a solution to this for a few days now and no luck. If anyone has been successful installing the libv8 gem for REE 1.8.7 on ML, could you please let me know the process you followed?
I have both the XCode LLVM compiler as well as the kennethreitz GCC package for 10.7+ v2 installed.
The output when trying to install with native extensions is:
Building native extensions. This could take a while...
ERROR: Error installing libv8:
ERROR: Failed to build gem native extension.
/Users/XXXXX/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby extconf.rb
*** 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=/Users/XXXXX/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby
extconf.rb:13: uninitialized constant Gem (NameError)
Checking for Python...
Gem files will remain installed in /Users/XXXXX/.rvm/gems/ree-1.8.7-2012.02/gems/libv8-3.3.10.4 for inspection.
Results logged to /Users/XXXXX/.rvm/gems/ree-1.8.7-2012.02/gems/libv8-3.3.10.4/ext/libv8/gem_make.out
(The results logged are the exact same as the error).
This worked for me.
RUBYOPT=-rrubygems gem install therubyracer
I was able to successfully install the libv8 gem on Mountain Lion on a freshly installed ree-1.8.7. I believe the issue you're seeing stems from the GCC version being used.
As is now described in the osx-gcc-installer's README you should switch from Kenneth Reitz's LLVM-version of GCC to the GCC 4.2 that is available via Homebrew or Macports.
Homebrew instructions:
http://coderwall.com/p/dtbuqg
MacPorts instructions:
http://coderwall.com/p/pagj2w
Note that you will want to set the CC path and establish the necessary symlink as described in those articles.

fatal error while bundle install (while installing libv8)

I work on windows7 (32-bit) and I get error that while bundle install;
Installing libv8 (3.3.10.4) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
C:/Ruby192/bin/ruby.exe extconf.rb
*** 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=C:/Ruby192/bin/ruby
Checking for Python... Unable to build libv8: Python not found!
So I can't complete "bundle install".
Install ActivePython version 2.7.2.5, then run:
gem install libv8 --version 3.11.8.0
to install the libv8 in Windows, the latest version 3.11.8.3 can not work in windows, but 3.11.8.0 can in Windows 7.
On windows 7, with ruby193 I installed python27, I added to the PATH variable the python's folder, I wrote gem install libv8 in the console and libv8 was succesfully installed
You need to install python since libv8 seems to depend on Python as you can see in project stats
I opened issue 29 on github and I learned that libv8 is not supported on windows. so there is no solution for the error. Just you can change your platform.

Resources