How can I configure gem install to use "install" from the right place? - configuration

When I try to install rails using gem on my Arch Linux machine, I get the following error:
$ gem install rails
...
...
make install
/usr/bin/install -c -m 0755 bcrypt_ext.so /home/gphilip/.rvm/gems/ruby-1.9.3-preview1/gems/bcrypt-ruby-3.0.1/lib
make: /usr/bin/install: Command not found
make: * [/home/gphilip/.rvm/gems/ruby-1.9.3-preview1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.so] Error 127
It turns out that on Arch Linux, the "install" binary is located at /bin/install. So on my system I have:
$which install
/bin/install
$
Since I have root access (it is my laptop!), I could easily "fix" this by creating a symlink at /usr/bin/install , but how would I do this otherwise?
How do I configure gem to use the "install" command from /bin/ instead of insisting on using the one in /usr/bin/ ?
I am asking this in case I am in a situation where I face the same problem and I don't have permissions to create symlinks in arbitrary places.

Find rbconfig.rb file in your ruby installation dir (example for my machine):
$ which ruby
/home/valentin/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
$ find /home/valentin/.rvm/rubies/ruby-1.8.7-p352 -name rbconfig.rb
/home/valentin/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/x86_64-linux/rbconfig.rb
In that file change line
CONFIG["INSTALL"] = '/usr/bin/install -c'
to
CONFIG["INSTALL"] = '/bin/install -c'
(Or whichever is the correct install path, I've had to change it back to /usr/bin, for example)
You might want to update other paths as well.
Or, you can just reinstall ruby.

Related

configure: error: invalid MySQL root directory

I've a problem installing sphinx with percona 5.6 on centos 6.4.
I'm getting the following error while building from source:
******************************************************************************
ERROR: cannot find MySQL include files.
Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.
If include files are installed on your system, but you are still getting
this message, you should do one of the following:
1) either specify includes location explicitly, using --with-mysql-includes;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in
your PATH environment variable.
To disable MySQL support, use --without-mysql option.
******************************************************************************
Percona-Server-devel is installed:
rpm -qa | grep -i percona
percona-release-0.0-1.x86_64
Percona-Server-server-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-client-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-devel-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-shared-56-5.6.16-rel64.2.el6.x86_64
What I've tried:
locate "libmysql"
/usr/lib64/libmysqlclient.so.18
/usr/lib64/libmysqlclient.so.18.0.0
/usr/lib64/libmysqlclient_r.so.18
/usr/lib64/libmysqlclient_r.so.18.0.0
/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient_r.so.16
/usr/lib64/mysql/libmysqlclient_r.so.16.0.0
/usr/lib64/mysql/libmysqlservices.a
than:
./configure --with-mysql=/usr/lib64/mysql --with-mysql-libs=/usr/lib64/mysql
./configure --with-mysql=/usr/lib64 --with-mysql-libs=/usr/lib64
./configure --with-mysql=/usr/bin/mysql --with-mysql-libs=/usr/bin/mysql
./configure --with-mysql=/usr
configure: error: invalid MySQL root directory '/usr/lib64/mysql';
neither bin/mysql_config, nor include/ and lib/ were found there
which mysql_config
/usr/bin/mysql_config
Have you tried installing mysql-devel ?
sudo yum install mysql-devel
If properly setup, try as suggested in the error message to point to these libs manually using a command like the following one (to be adapted to your environment)
./configure --with-mysql-includes=/usr/local/src/mysql-XXX/include

Error running mysql_install_db: could not find ./bin/my_print_defaults

I seem to be having an issue getting MySQL 5.6.1.5 to install from Source. I am running RHEL 6.
I was able to perform the cmake, make, and make install without issues.
I am attempting to run the mysql_install_db binary and when I do I get the following error:
Fatal ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to copy the software
into the correct location ready for operation.
If you are using a binary release, you must either bat at the top level of the
extracted archive, or pass the --basedir option pointing to that location.
So I did a check for my_print_defaults using which my_print_defaults, unfortunately it was not found on my machine.
I did a locate my_print_defaults as well just for the heck of it and said it was located in /usr/bin/my_print_defaults, however, when I checked /usr/bin for the binary, it was not actually there.
I would try to use mysql_install_db --basedir=/usr/bin but I know this won't work as the which and locate commands confirm my_print_defaults isn't on my machine.
I looked at mysql_install_db giving error, but that error was not similar to this one.
Please ignore question, I didn't bother to try running find / -name my_print_defaults and found it in /usr/local/mysql/bin/
I searched packages for my_print_defaults with
apt-file search my_print_defaults
If my_print_defaults is missing on your system (which my_print_defaults), first find out which db is installed with:
dpkg -l |grep -E 'maria|mysql'|grep ii|grep server
If you have installed mariadb, try reinstall mariadb:
sudo apt install --reinstall mariadb-server-core-10.1
If you don't find a solution with mariadb, swap back to mysql with
sudo apt install mysql-server

Error while installing json gem 'mkmf.rb can't find header files for ruby'

For context, it on a remote server which has a firewall. I'm setting up my environment through a proxy. I have ruby 1.8.7. When I try to gem install..
sudo gem install --http-proxy <host address>:<port> json
I get the following error:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/json-1.8.1 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Since I was unsure what the problem is, I googled and found these
gem install: Failed to build gem native extension (can't find header files) - the instructions here seem to be specific to the gem being installed.
How to install json gem - Failed to build gem native extension This seems to be slightly different error.
Any hints? Thanks!
Modern era update, as stated by mimoralea:
In case that you are using ruby 2.0 or 2.2 (thanks #patrick-davey).
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev
or, generic way:
sudo apt-get install ruby-dev
or
sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev
The first link you’ve posted is exactly your case: there is no ruby development environment installed. Development env is needed to compile ruby extensions, which are mostly written in C. Proxy has nothing to do with the problem: everything is downloaded fine, just compilation fails.
I would suggest you to install ruby-dev (ruby-devel for rpm-based distros) package onto you target machine.
gcc package might be needed as well.
Try:
$ sudo apt-get install ruby-dev
Or, for Redhat distro:
$ sudo yum install ruby-devel
Or, for [open]SuSE:
$ sudo zypper install ruby-devel
For Xcode 11 on macOS 10.14, this can happen even after installing Xcode and installing command-line tools and accepting the license with
sudo xcode-select --install
sudo xcodebuild -license accept
The issue is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
which on macOS 10.14 with Xcode 11 prints the non-existent path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
However, Xcode 11 installs a macOS 10.14 SDK within /Library/Developer/CommandLineTools/SDKs/MacOS10.14.sdk. It isn't necessary to pollute the system directories by installing the old header files as suggested in other answers. Instead, by selecting that SDK, the appropriate ruby2.3 headers will be found:
sudo xcode-select --switch /Library/Developer/CommandLineTools
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
This should now correctly print
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0
Likewise, gem install should work while that SDK is selected.
To switch back to the current Xcode SDK, use
sudo xcode-select --switch /Applications/Xcode.app
In case that you are using ruby 2.0 or 2.2 (thanks #patrick-davey) or 2.3 (thanks #juanitofatas).
sudo apt-get install ruby-dev
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev
And you get the pattern here...
I also encountered this problem because I install Ruby on Ubuntu via brightbox, and I thought ruby-dev is the trunk of ruby. So I did not install. Install ruby2.3-dev fixes it:
sudo apt-get install ruby2.3-dev
For those who are getting this on Mac OS X you may need to run the following command to install the XCode command-line tools, even if you already have XCode installed:
sudo xcode-select --install
Also you must agree the terms and conditions of XCode by running the following command:
sudo xcodebuild -license
I had a similar problem using cygwin to run the following command:
$ gem install rerun
I solved it by installing the following cygwin packages:
ruby-devel
libffi-devel
gcc-core
gcc-g++
make
automake1.15
Most voted solution didn't work on my machine (linux mint 18.04).
After a careful look, i found that g++ was missing.
Solved with
sudo apt-get install g++
in case you use SUSE
sudo yast2 -i ruby-devel
Xcode 11 / macOS Catalina
On Xcode 11 / macOS Catalina, the header files are no longer in the old location and the old /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg file is no longer available.
Instead, the headers are now installed to the /usr/include directory of the current SDK path:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
Most of this directory can be found by using the output of xcrun --show-sdk-path. And if you add this path to the CPATH environment variable, then build scripts (including those called via bundle) will generally be able to find it.
I resolved this by setting my CPATH in my .zshrc file:
export CPATH="$(xcrun --show-sdk-path)/usr/include"
After opening a new shell (or running source .zshrc), I no longer receive the error message mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h and the rubygems install properly.
Note on Building to Non-macOS Platforms
If you are building to non-macOS platforms, such as iOS/tvOS/watchOS, this change will attempt to include the macOS SDK in those platforms, causing build errors. To resolve, either don't set CPATH environment variable on login, or temporarily set it to blank when running xcodebuild like so:
CPATH="" xcodebuild --some-args
In Fedora 21 and up, you simply open a terminal and install the Ruby Development files as root.
dnf install ruby-devel
On Mac 10.14, the header files don't seem to be installed in the correct place. Rather than changing paths like the other fixes, I was able to just run this:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Follow the instructions and it resolved this problem for me.
You may need to install gcc after install ruby-devel
Xcode -> Preferences -> Locations
change Command Line Tools to Xcode 11.2.1
You need to install the entire ruby and not just the minimum package. The correct command to use is:
sudo apt install ruby-full
The following command will also not install a complete ruby:
sudo apt-get install ruby2.3-dev
For Ubuntu 18, after checking log file mentioned while install
Results logged to /var/canvas/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nio4r-2.5.2/gem_make.out
with
less /var/canvas/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nio4r-2.5.2/gem_make.out
I noticed that make is not found. So installed make by
sudo apt-get install make
everything worked.
I faced a similar issue on Xcode 12 with macOS 10.15 and cocoapods. Just make sure that the xcode-select command points to the SDK you want to build against. It should build without issues afterwards.
BEFORE you follow the tip from Joki's answer (below) and IF :
you have MacOS 10.14.6
at /Library/Developer/CommandLineTools/SDKs/ you have folders
MacOSX.sdk(symbolic), MacOSX10.14.sdk, MacOSX10.15.sdk
Move MacOSX10.15.sdk to anywhere (admin privileges needs)
Delete symbolic link (admin privileges needs)
At /Library/Developer/CommandLineTools/SDKs/ create another symbolic link now to MacOSX10.14.sdk folder using (admin privileges needs)
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk MacOSX.sdk
Now you can follow Joki's answer
WARNING!
If you move MacOSX10.15.sdk folder to /Library/Developer/CommandLineTools/SDKs/ again, the command
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
will show MacOSX10.15.sdk folder like default again, nowadays I dunno how to fix it! My suggestion, compress the folder and put the original folder until fix will be available.
macOS RubyMine Gem installation failure
My problem with this error message was when trying to install a Gem via RubyMine. It didn't like that I had changed the global Ruby version with rbenv, so I fixed it by changing back to the system default Ruby version with:
rbenv global system
and restarted RubyMine.
sudo apt-get --reinstall install ruby
try it for ubuntu 16.04

linux mysql-server can't find mysql_config

I have a running (in production) mysql instance on my linux server (ubuntu-10.10) however I cannot find my mysql_config file.
command and output:
~$ locate mysql_config
~$
I've heard/read that I need the libmysqlclient-dev package installed to be able to use mysql_config but I don't want to break my current production instance. I want to make sure installing this dev package is not going to have adverse effects on my current mysql databases.
Furthermore, where can I find the source download for libmysqlclient-dev to install manually? In my current situation (behind corporate proxy) I am not permitted to use apt-get's.
UPDATE
this is stemming from attempting to install python-MySQLdb from source. the setup.py file is requiring the mysql_config path and continues to break when trying to use anything but that file.
The mysql_config executable is by default located in the bin directory of the MySQL server installation if you install it from precompiled binaries. But if you install it using apt-get it may not exist on your server.
Try:
sudo apt-get install libmysqlclient-dev
yum install mariadb-devel works for Centos 7 too, this puts the mysql_config into all the places that pip install mysqlclient requires/looks for it.
In Ubuntu 13.04 installation, it is at /usr/bin/mysql_config
Try /etc/my.cnf, that is the standard file for mysql config.
You can also do:
find / -name my.cnf -type f
On Fedora, install the mariadb-devel package, and you should have the binary.

Trying to install Perl-Mysql DBD, mysql_config can't be found

Here's the output:
Ian-MacBook-Pro:DBD-mysql-4.011 ianseyer$ sudo Perl Makefile.PL
Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.
Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user 'root' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to 'root'#'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
I've researched the issue and tried making a symlink to no avail.
Do I have to compile this myself?
If you installed the mysql server that everybody installs:
sudo apt-get install mysql-server (or something like this)
you are missing a few extra files on which the makefile for this perl module depends.
You can try to work around this issue by installing the following package:
sudo apt-get install libmysqlclient-dev
REFERECE:
http://cpansearch.perl.org/src/RUDY/DBD-mysql-2.9008/INSTALL.html#configuration
Applying to ubuntu/debian users (I'm running U-12.0.4), it was suggested above that users do:
sudo apt-get install libmysqlclient-dev
But then there is another problem with the maketest portion of the install where the "password: NO" FAILED. To bypass that test, just use force:
sudo cpan -f DBD::mysql
if u r using ubuntu , u can easily install using the below cmd
sudo apt-get install libdbd-mysql-perl
for more detail check the cpan install.pod consist detail about other Linux flavor
Install the mysql-devel package that pertains to your distro and mysql server version.
You just need mysql-server and mysql-devel installed locally so that cpan can build the module, you can probably remove the mysql server afterwards.
Find the script mysql_config.pl under your MySQL directory, and run Makefile.PL like:
perl Makefile.PL --mysql_config=/path/to/mysql-5.x.y.zzz/bin/mysql_config.pl
If you try to install via CPAN you cannot, as far as I know, set the --mysql_config option directly. And, including the directory containing mysql_config in the PATH environment variable does not seem to help.
However, if you do have the file mysql_config available somewhere, you can do the following to make the install succeed:
ln -s /path/to/mysql_config /usr/local/bin/
Then, remove the symbolic link after the DBD::mysql installation.
The tests during install will still fail, unless you have installed MySQL in some central/default location on your system, but installation will still succeed.
If you do not have mysql_config available, you can get it from a tar.gz download of the MySQL Community Server from mysql.com. It will be located in the bin/ subdirectory of the extracted files. If you want to have MySQL installed on your system, a better option is probably to download the RPMs and install them, or install via the package management system of your OS.
Try yum install mariadb-devel for CentOS 7 and then
run the required Perl module installation such as cpan DBD::mysql
I was getting make test errors. This helped me;
perl Makefile.PL --testuser=bob --testpass=bobtest
I solved installing libmariadbclient-dev, libmariadb-dev and mariadb-client on debian 9.13
apt install mariadb-client libmariadbclient-dev libmariadb-dev

Categories