An error occurred while installing rugged - ruby-on-rails

Following this tutorial [link] to install gitlab on a dedicated server. I need to :
sudo -u git -H bundle install --deployment --without development test postgres aws
But an error occurred while installing rugged :
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for cmake... no
ERROR: CMake is required to build Rugged.
*** 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=/usr/local/bin/ruby
Gem files will remain installed in /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/rugged-0.21.2 for inspection.
Results logged to /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/rugged-0.21.2/ext/rugged/gem_make.out
An error occurred while installing rugged (0.21.2), and Bundler cannot continue.
Make sure that `gem install rugged -v '0.21.2'` succeeds before bundling.
So I installed rugged -> I installed CMake & config-pkg :
/home/git/gitlab$ sudo gem install rugged
Building native extensions. This could take a while...
Successfully installed rugged-0.21.2
Parsing documentation for rugged-0.21.2
unable to convert "\xC0" from ASCII-8BIT to UTF-8 for lib/rugged/rugged.so, skipping
1 gem installed
But it doesnt change anything :
Errno::EACCES: Permission denied - /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/rugged-0.21.2/LICENSE
An error occurred while installing rugged (0.21.2), and Bundler cannot continue.
Make sure that `gem install rugged -v '0.21.2'` succeeds before bundling.
Any idea ?

For OSX if you're using homebrew:
brew install cmake
bundle install

First, try installing cmake:
sudo apt-get install cmake
Then, repeat the command:
sudo -u git -H bundle install --deployment --without development test postgres aws

For me, gem was complaining about pkg-config missing dependence, so I did:
sudo apt-get install pkg-config
and then
sudo gem install rugged -v '0.22.2'
after that, I revert to my older version of gitlab and re-run the script for the upgrade.
My older version of gitlab was 6.9.2 and the upgraded version 8.0.5

Can fix this problem only that way:
download from https://cmake.org/download/. Extract the downloaded tar file and then:
cd $CMAKE_DOWNLOAD_PATH
./configure
make
make install
And after this steps I could successfully run:
gem install rugged -v '0.26.0'

Note: The above mentioned solutions did not work for me.
Here is the error log I got
checking for gmake... no
checking for make... yes
Building Rugged using system libraries.
libgit2 version is not compatible, expected ~> 0.99.0
*** 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.
It was mainly saying libgit2 version is not compatible, expected ~> 0.99.0
and I tried gem install rugged -v '0.99.0' and then bundle install.
then the problem is solved.

Mac OSX 10.6 or later please refer to this url:
http://www.cmake.org/download/

For me it was Openssl problem in a WSL ubuntu 20.04 env
Run
apt install cmake libssl-dev
might also help to run
apt install ruby-dev pkg-config

Related

How to install ruby-odbc gem on M1 Mac

I am trying to get a rails project running on an M1 mac.
I have to use ruby 2.6.2 and rails 5.2.3
I am using rbenv 1.1.2 and homebrew 3.0
When I run bundle install, I get this error
An error occurred while installing ruby-odbc (0.99999), and Bundler cannot continue.
Make sure that `gem install ruby-odbc -v '0.99999'` succeeds before bundling.
So then I run gem install ruby-odbc -v '0.99999'
This leads to another error
ERROR: Error installing ruby-odbc:
ERROR: Failed to build gem native extension.
current directory: /Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/ruby-
odbc-0.99999/ext
/Users/david.lee/.rbenv/versions/2.6.2/bin/ruby -I
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20210208-46271-1tguvxe.rb
extconf.rb
checking for version.h... no
checking for sql.h... no
*** 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/david.lee/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME)
--with-odbc-dir
--without-odbc-dir
--with-odbc-include
--without-odbc-include=${odbc-dir}/include
--with-odbc-lib
--without-odbc-lib=${odbc-dir}/lib
ERROR: sql.h not found
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/ruby-odbc-0.99999/mkmf.log
When I stackoverflow this error, I get this post which tells me to brew install unixodbc, so I do that and try to bundle install again, which gives me the same error.
All the stackoverflow posts related to sql.h files not being installed do not solve my issue.
HOW DO I INSTALL THIS GEM?
Thanks to a co-worker, I got this resolved.
You need to install the gem while pointing it to the unixodbc directory
This was the line that installed it for me
gem install ruby-odbc -- --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.9
To find your unixodbc path, run brew info unixodbc
That will give you the path and your version number of unixodbc. Then you put the path and version number in the appropriate spot
gem install ruby-odbc -- --with-odbc-dir=put your path and version number of unixodbc here
None of the above solutions worked for me when I had this error. This is what worked for me:
bundle config set build.ruby-odbc --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.11
Per this StackOverflow post
If you need this to work while running the bundle command, do the following:
bundle config build.odbc --with-odbc-dir=$(brew --prefix unixodbc)

Bundle Install / TheRubyRacer gem cannot be installed on MacOS Catalina 10.15.2

I'm getting tired of error when trying to bundle install and install therubyracer.
I've tried everything from around the net and nothing helps.
Already installed libv8 and x-code setup.
Appreciate your help!
After command sudo gem install therubyracer -v '0.12.3', I'm receivin error:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/therubyracer-0.12.3/ext/v8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20191219-41979-115mu26.rb extconf.rb
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Library/Ruby/Gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.
However, your system version of v8 could not be located.
Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
from /Library/Ruby/Gems/2.6.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/therubyracer-0.12.3/mkmf.log
extconf failed, exit code 1 ```
I've found the solution for this error.
If you have a problem with bundle install check this:
gem list libv8 --remote --all
gem install libv8 -v 3.16.14.19 -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/Users/YOUR_NAME/homebrew/opt/v8#3.15
It works for me, after few hours of fighting with every solution I can find.
Hope it'll help someone.
I was stuck on the same issue and got help from this gist.
brew install v8#3.15
gem install libv8 -v 'YOUR_VERSION' -- --with-system-v8
gem install therubyracer -v 'YOUR_VERSION' -- --with-v8-dir=/usr/local/opt/v8#3.15
bundle install
I am using macOS Catalina version 10.15.3 and ruby version 2.6.3. I hope it helps!
I have faced the same issue recently in Mac OS 10.15.7
brew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v
gem install therubyracer -v '0.12.3' -- --with-system-v8 --with-v8-dir=/usr/local/opt/v8#3.15
Note: while installing ruby race it installed only after putting both the options together --with-system-v8 and --with-v8-dir and pointing to that directory.
Please do verify if the folder exist in that path or not before installing.
Uninstalling v8 and install v8#3.15 on a fresh Catalina install worked for me.
$ brew uninstall v8
$ brew install v8#3.15

mysql2 gem fails on bundle install, despite installing using `gem install...` command

Here is the log from my bundle install
Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
...
...
Cannot find mysql_config at /usr/local/opt/mysql#5.6/bin/mysql_config
--with-ldflags=-L/usr/local/opt/openssl/lib
--with-cppflags=-I/usr/local/opt/openssl/include
-----
*** 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/admin/.asdf/installs/ruby/2.6.3/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
To see why this extension failed to compile, please check the mkmf.log which can be found
here:
/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2 for
inspection.
Results logged to
/Users/admin/development/locari/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/gem_make.out
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds
before bundling.
So I do what it says, and run sudo gem install mysql2 -v '0.5.2' --source
$ sudo gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
Successfully installed mysql2-0.5.2
Parsing documentation for mysql2-0.5.2
Done installing documentation for mysql2 after 0 seconds
1 gem installed
And it installs fine! But when I run bundle install again, I get the same error. I've tried uninstalling, unlinking, and reinstalling mysql in brew.
What can I try next??
Run these commands first:
bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib"
Then run bundle install it works.
Installation on M1 macs
This method helped me on ruby v2.7.2 and macOS Big Sur 11.4.
Install dependencies
brew install mysql zstd openssl
Install the gem
gem install mysql2 -- --with-ldflags="-L $(brew --cellar zstd)/1.5.0/lib -L $(brew --prefix openssl)/lib" --with-ldlibs="-lzstd -lssl" --with-cppflags="-I $(brew --prefix openssl)/include"
As an alternative, you can modify bundler config:
bundle config --local build.mysql2 --with-ldflags="-L $(brew --cellar zstd)/1.5.0/lib -L $(brew --prefix openssl)/lib" --with-ldlibs="-lzstd -lssl" --with-cppflags="-I $(brew --prefix openssl)/include"
and run bundle install.
Use build options with bundler.
Try running this in your application directory:
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
This sets it just for your application, which can be handy for checking into your repo if others need a similar configuration. But you can also make it a global configuration on your computer by replacing --local with --global and it will apply to all your bundle install commands on your User account.
Update
This actually didn't end up working for me but I'll leave it here because it should have worked. I basically just had to run:
gem install mysql2 -v '0.5.3' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Instead of using bundler, even though setting this build config should have done this.

Error while bundle install for idn-ruby

I have twitter-text gem in my application.
When I do a bundle install I am getting the below error.
Need to solve it on high priority.
I also went to the github page https://github.com/twitter/twitter-text/issues/225
but could not find a solution there.
I tried to install directly using the line below but got the same error.
gem install idn-ruby -v '0.1.0'
Error
Fetching idn-ruby 0.1.0
Installing idn-ruby 0.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/gems/idn-ruby-0.1.0/ext
/home/inuscg/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20180427-13217-1wpq9sy.rb extconf.rb
checking for main() in -lidn... no
ERROR: could not find idn library!
Please install the GNU IDN library or alternatively specify at least one
of the following options if the library can only be found in a non-standard
location:
--with-idn-dir=/path/to/non/standard/location
or
--with-idn-lib=/path/to/non/standard/location/lib
--with-idn-include=/path/to/non/standard/location/include
*** 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=/home/inuscg/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-idn-dir
--without-idn-dir
--with-idn-include
--without-idn-include=${idn-dir}/include
--with-idn-lib
--without-idn-lib=${idn-dir}/lib
--with-idnlib
--without-idnlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/extensions/x86_64-linux/2.3.0/idn-ruby-0.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/gems/idn-ruby-0.1.0 for inspection.
Results logged to /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/extensions/x86_64-linux/2.3.0/idn-ruby-0.1.0/gem_make.out
An error occurred while installing idn-ruby (0.1.0), and Bundler cannot continue.
Make sure that `gem install idn-ruby -v '0.1.0'` succeeds before bundling.
In Gemfile:
twitter-text was resolved to 2.1.0, which depends on
idn-ruby
Thank you in advance
As per the error show in logs
ERROR: could not find idn library!. idn library is required to install twitter text. Try to install that first and then install the gem. Try with
sudo apt-get install libldap2-dev
sudo apt-get install libidn11-dev
Hope this solves your problem.
For mac:
brew install libidn
On a Mac, you can do:
$ brew install libidn
If you're using Mac OS, then here's how to install libidn:
$ brew install libidn
On Centos 7 I had to install libidn-devel via yum install libidn-devel
If you are using Windows and facing same error, then try
Instruction for Windows
Get the appropriate build of GNU LibIDN Library from here
Unpack it where you prefer (e.g. c:\tmp\libs\libidn)
Add option to bundler config
BUNDLE_BUILD__IDN-RUBY: "--with-idn-dir=C:/tmp/libs/libidn/"
Launch bundler install
As for me I used libidn-1.33-win64.zip package
You're required to install LibIDN beforehand, since the gem is just ruby bindings for it.
Requirements
GNU LibIDN Library
Rake to run the tests and generate the documentation
RubyGems to produce a Gem package
Ruby 1.9.1 or above. Patches welcome to make this work in 1.8.7
The specific download method would depend on your OS, but if it's Ubuntu, try sudo apt-get install libidn

Installing rmagick gem on ubuntu 14.04

I'm trying to deploy an app on OpsWorks, but there are problems with installing rmagick gem. I have the following OS packages:
libmagickwand-dev imagemagick libmagickcore-dev
Below is the log file with errors during deployment:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 0.0.0. Can't find Magick-config in /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
*** 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=/usr/local/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in /home/deploy/.bundler/myapp/ruby/2.1.0/gems/rmagick-2.13.3 for inspection.
Results logged to /home/deploy/.bundler/myapp/ruby/2.1.0/extensions/x86_64-linux/2.1.0/rmagick-2.13.3/gem_make.out
An error occurred while installing rmagick (2.13.3), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.13.3'` succeeds before bundling.
STDERR:
---- End output of sudo su - deploy -c 'cd /srv/www/myapp/releases/20140929182350 && /usr/local/bin/bundle install --path /home/deploy/.bundler/myapp --without=test development' 2>&1 ----
Ran sudo su - deploy -c 'cd /srv/www/myapp/releases/20140929182350 && /usr/local/bin/bundle install --path /home/deploy/.bundler/myapp --without=test development' 2>&1 returned 5
[2014-09-29T18:24:08+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
In your shell, run the following command:
apt-get install libmagickwand-dev
I had the same problem after upgrading ubuntu to 15.05, some how the Magick-config file is no longer in my PATH.
To fix this I first found the location of Magick-config
sudo find / -name "Magick-config"
which was /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config then I added it to the path. Bundle succeeded afterwards.
sudo apt-get install libmagickwand5 libmagickwand-dev
gem install rmagick -v 2.13.3
Install Imagemagick-dev libraries
Ubuntu systems: sudo apt-get install libmagickwand-dev
RHEL systems: yum install ImageMagick-devel
Mac: brew install imagemagick
In Ubuntu 14.04 I also needed to install the libgmp-dev library to get working the newer rmagick 2.15.4 version:
sudo apt-get install libgmp-dev
Hope this helps!
to fix it permanently we could just do:
ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
First of all we need to search configuration
sudo find / -name "Magick-config"
You will get output something like this:
/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config
Now you just need to setup bin location in your environment by using this:
PATH=$PATH:/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/
Don't forget to remove Magick-config from end of line.

Resources