Error installing TinyTDS on OSX 10.6 via gem install tiny_tds - freetds

I have been trying to install the TinyTDS gem on a Macbook with OSX 10.6. I was successful in installing Free TDS -- confirmed that it works via:
tsql -H SERVER -p 1433 -U username.
The error I'm getting from gem install tiny_tds is:
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
/Users/jason/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... no
-----
freetds is missing.
-----
*** 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.
I've tried specifying the TDS lib and include dirs (/usr/local/lib and /usr/local/include) without luck. I've tried reinstalling FreeTDS from source manually as well as via homebrew, but that made no difference.
I've seen a few similar issues posted, but they seem to reference an issue with locating iconv libraries which I appear to be moving beyond.
Any suggestions or references I may have overlooked? Thanks in advance.

Same problem on Ubuntu 14.04 resolved with:
sudo apt-get install freetds-dev
gem install tiny_tds
Log output:
Building native extensions. This could take a while...
/home/david/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /mnt/datapart/david in PATH, mode 040777
Successfully installed tiny_tds-0.6.1
Parsing documentation for tiny_tds-0.6.1
Installing ri documentation for tiny_tds-0.6.1
Done installing documentation for tiny_tds after 0 seconds
1 gem installed

You need to install freetds with homebrew
brew update # always a good idea to update homebrew before installing anything!
brew install freetds

In my case, it seems the symlinks were not configured correctly, and using "brew link freetds" threw errors which required opening up some permissions. I tried just about everything else, and this is finally what worked:
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/images
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/reference
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/doc/freetds/userguide
devMac:0.95.18 Me$ sudo chown -R $USER /usr/local/share/man/man5
devMac:0.95.18 Me$ brew link --overwrite freetds
Linking /usr/local/Cellar/freetds/0.95.18... 2812 symlinks created
devMac:0.95.18 Me$ sudo gem install tiny_tds
Building native extensions. This could take a while...
Successfully installed tiny_tds-0.6.2
Parsing documentation for tiny_tds-0.6.2
Installing ri documentation for tiny_tds-0.6.2
Done installing documentation for tiny_tds after 0 seconds
1 gem installed
Disclaimer: I am in the early stages of learning this framework and do not have an understanding of the repercussions of using overwrite or changing these permissions.

In my case, installing Ruby 2.3.0 using brew install ruby worked. I got the idea from this question Cannot install tiny_tds on os.x 10.9.4.

Related

ruby on rails rmagick can't use, cloud9

I am using cloud9.
I want to use gem 'rmagick', but using bundle, following error message occurs...
please help...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/rvm/gems/ruby-2.4.0/gems/rmagick-2.16.0/ext/RMagick
/usr/local/rvm/rubies/ruby-2.4.0/bin/ruby -r
./siteconf20180204-XXXXXX-oyXXpq.rb extconf.rb checking for gcc... yes
checking for Magick-config... no checking for pkg-config... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc' to the
PKG_CONFIG_PATH environment variable No package 'MagickCore' found
checking for outdated ImageMagick version (<= 6.4.9)... * 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.
I just spun up a Cloud9 VM and tried it.
My Cloud9 VM I tried used yum as a package manager. Meaning I installed ImageMagick via sudo yum install ImageMagick-devel... when I did that my gem install rmagick worked.
Didn't try it with Bundler, but if gem install works then it should work in Bundler also.
Using the command prompt install/update imagemagick via
sudo apt-get update
Then
sudo apt-get install imagemagick
See more
Hope it helps

Chef Client Run gives 'Failed to build gem native Extension' while installing tiny_tds gem

My requirement is to use tiny_tds to connect to SQLServer Database as part of a chef client run which is running on Ubuntu OS. So, as part of this task, I have written a cookbook in which I have included the following line in the metadata.rb file:
gem 'tiny_tds'
This should install tiny_tds gem as per the chef documentation. But, I get an error saying 'Failed to build gem native Extension'. While some sites suggest on the issue being related to FreeTDS, the solutions are not clear enough to solve this issue.
Edit: Adding more info on the issue
I also tried manually installing freetds with the following commands:
sudo apt-get install wget
sudo apt-get install build-essential
sudo apt-get install libc6-dev
sudo wget http://www.freetds.org/files/stable/freetds-1.00.21.tar.gz
tar -xzf freetds-1.00.21.tar.gz
cd freetds-1.00.21
sudo ./configure --prefix=/usr/local --with-tdsver=7.3
sudo make
sudo make install
and then when I run the command
gem install tiny_tds
on the terminal, it successfully installs using native dependencies.
But the issue still exists when I do a chef client run with the command
sudo chef-client -o "recipe[tiny_tds_cookbook]"
StackTraces:
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/tiny_tds-2.1.1/ext/tiny_tds
/opt/chef/embedded/bin/ruby -r ./siteconf20180121-23372-1r1mxpl.rb extconf.rb
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... no
checking for dbanydatecrack() in -lsybdb... no
Failed! Do you have FreeTDS 0.95.80 or higher installed?
extconf.rb failed
You probably need to install either the compiler or the ruby development headers. We do not recommend using the gem metadata dependency system for gems that require C extensions as you would need to install the compiler before Chef starts, which is usually a thing Chef would do itself. For situations like this, the older chef_gem resource is generally better because you can use a cookbook like build-essential to install the compiler tools before installing the gem.

Error when installing Ruby on Rails: "Failed to build gem native extension"

I'm running Crunchbang 11 (Debian-based).
I'm trying to install Ruby on Rails, like this:
gem install rails --version 4.0.0
I get the error "Failed to build gem native extension".
My ruby is version 2.0.0p247, my RubyGems is 2.0.0.
What's the issue here?
This is the full error output:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
creating Makefile
make
compiling atomic_reference.c
linking shared-object atomic_reference.so
make install
/usr/bin/install -c -m 0755 atomic_reference.so /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/lib/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/usr/bin/install: cannot create regular file `/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/lib/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux': No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10 for inspection.
Results logged to /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/ext/gem_make.out
My env:
ORBIT_SOCKETDIR=/tmp/orbit-erlkoenig
SSH_AGENT_PID=2695
rvm_bin_path=/home/erlkoenig/.rvm/bin
GEM_HOME=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247
SHELL=/bin/bash
TERM=xterm-256color
XDG_SESSION_COOKIE=9e0343c07c890bd2d60ee6a750f36c6c-1373892339.852749-193038580
IRBRC=/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/.irbrc
WINDOWID=39845892
GNOME_KEYRING_CONTROL=/home/erlkoenig/.cache/keyring-g6PRS5
MY_RUBY_HOME=/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247
USER=erlkoenig
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
rvm_path=/home/erlkoenig/.rvm
SSH_AUTH_SOCK=/tmp/ssh-XVmUxMD7LHwi/agent.2651
rvm_prefix=/home/erlkoenig
PATH=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/bin:/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247#global/bin:/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/bin:/home/erlkoenig/.rvm/bin:/home/erlkoenig/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/erlkoenig/.rvm/bin:/home/erlkoenig/.scripts:/home/erlkoenig/.scripts/netlogo-5.0.3:/opt/node/bin
MAIL=/var/mail/erlkoenig
PWD=/home/erlkoenig
EDITOR=vim
GNOME_KEYRING_PID=2575
LANG=en_US.UTF-8
rvm_env_string=ruby-2.0.0-p247
rvm_version=1.21.9 (stable)
SHLVL=1
HOME=/home/erlkoenig
rvm_ruby_string=ruby-2.0.0-p247
LOGNAME=erlkoenig
GEM_PATH=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247:/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247#global
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9eOdnYZelY,guid=a5db4ca68e107a48a04c8b8e51e3eef4
DISPLAY=:0.0
RUBY_VERSION=ruby-2.0.0-p247
XAUTHORITY=/home/erlkoenig/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command
gem update --system 2.0.3
Run the following command:
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
Then,
sudo gem install rails
Just a follow up ... on different solution...
it may be that you are on a mac and rails cannot find the right compiler for c headers.
just install xcode from apps store / homebrew or go to terminal ...
$ xcode-select --install
complete the installation and agree on the licensing etc, then ...
$ sudo gem install rails
Got the same issue when installing rails with the command
"gem install rails -v 5.1.2" on windows7, solved after installing "MSYS2 and MINGW development toolchain" (command ridk install then option 3)..It took a while to finish the installation and then i installed rails without any problem
For me this helped:
sudo apt-get install ruby-dev
I could solve this way
rvm use ruby --install --default
and then try again.
gem install rails --no-document
This worked for me:
sudo ln -s /bin/mkdir /usr/bin/mkdir
I kept encountering this error when I ran gem install rails -v 5.2.0:
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:199: .sitearchdir.-.racc.time] Error 127
make install failed, exit code 2
So I ran this command and it fixed it for me:
sudo ln -s /bin/mkdir /usr/bin/mkdir
Originally found: https://stackoverflow.com/a/64653052
Try
sudo gem install rails --version 2.0
to install libraries.
For anyone got the error:"Failed to build gem native extension”, while running sudo gem install rails, and it said somethings about "nokogiri".
It is possible because you are using the same ruby version as system is using (for mac user). The solution would be install RVM, use RVM to install another ruby version.
So now you have 2 Ruby versions on your machine, RVM will automatically switch to the newly installed version. now, you can run gem install rails without error and without sudo as well.
i'm running elementary os 5 and what i do is.
sudo gem update --system
and then try again.
sudo gem install rails
On Fedora 30, I ran into this problem "Failed to build gem native extension". The log error was "gcc: fatal error: cannot read spec file ‘/usr/lib/rpm/redhat/redhat-hardened-cc1’: No such file or directory". The solution was found here.
If you installed all the above, but the extensions would still not compile, you are probably running a Fedora image that misses redhat-rpm-config package. In that case gcc compiler would complain about one of the following:
gcc: error: conftest.c: No such file or directory
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
To solve this, simply run sudo dnf install redhat-rpm-config.
While installing rails 7 when I ran the command
sudo gem install rails
I got the same errors. I tried several suggestions, but in vain. At last one suggestion from the web helped me. I have been asked to run following command :
sudo apt-get install libmagickwand-dev
and then try again installing rails. Here is the link to that site : https://askubuntu.com/questions/600068/cant-install-a-ruby-package-failed-to-build-gem-native-extension
It worked !!!
I had the same error when installing rails, but I solved it by running the command: gem install rails without adding sudo.
I got a similar error installing rails 7.0.4 because of websocket-driver 0.7.5
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver:
ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r ./siteconf20221124-7-9o2qxo.rb extconf.rb
creating Makefile
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in /usr/local/bundle/gems/websocket-driver-0.7.5 for inspection.
Results logged to /usr/local/bundle/extensions/aarch64-linux/3.1.0/websocket-driver-0.7.5/gem_make.out
The following command solved my problem
apt install -y build-essential

pg gem install fails saying version is too old?

I am trying to install the pg (PostreSQL) gem for Ruby. I am receiving this error:
postgres/9.2-pgdg/bin/64/pg_config
Using config values from /location/to/install/postgres/9.2-pgdg/bin/64/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.
*** 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.
PostgreSQL version: postgres (PostgreSQL) 9.2.3
OS: solaris 10
I have also tried:
gem install pg -- --with-pgsql-lib=/location/of/install/postgres/9.2-pgdg/lib/64/ --with-pg-config=/location/of/install/postgres/9.2-pgdg/bin/64/pg_config
I have no idea why this error is occurring and I cannot find any useful info on Google.
Any help is greatly appreciated.
Lots of things can go wrong installing a database client, the gem and using it.
I generally install PostgreSQL from source, not from a distro. At that point I know I have all the source and know exactly where things got installed. That's important when installing the gem that talks to the client drivers.
I also rely on installing Ruby from source, either by directly installing it myself, or by using rbenv or RVM if it's on one of my development boxes. Then I also install the pg gem directly, using gem install pg; I've had too many bad experiences using distros when installing languages so I go old-school on it.
I wrote a little script I use on my Mac OS systems, that I've found useful for my CentOS Linux boxes:
#!/bin/sh -x
PATH=/Library/PostgreSQL/9.2/bin:$PATH
gem install pg
I adjust the PATH addition depending on where PostgreSQL got installed, and it seems to do the trick. I've used the longer, more "comprehensive" options also, but this seems to work as well.
The issue is that the installer needs to dig out installation information from the pg_config executable and being able to find pg_config does the trick.
I was going nuts with this until I realized that postgresql-devel and postgresql-libs were from 8.1.23!!!
$ yum list installed postgres*
Loaded plugins: fastestmirror, security
Installed Packages
postgresql-devel.i386 8.1.23-10.el5_10 installed
postgresql-devel.x86_64 8.1.23-10.el5_10 installed
postgresql-libs.i386 8.1.23-10.el5_10 installed
postgresql-libs.x86_64 8.1.23-10.el5_10 installed
---------------
$ sudo yum install postgresql94-libs
$ sudo yum install postgresql94-devel
$ gem install pg
Successfully installed pg-0.18.1
Installing and linking postgresql from homebrew fixed it for me:
brew install postgresql
brew unlink postgresql91
brew link --overwrite postgresql

make error when installing nokogiri gem using rvm on ruby-1.8.7-p334 [ x86_64 ]

When I try to install nokogiri gem on ruby-1.8.7-p334 [ x86_64 ] on Mac OS X 10.6, I get the following error:
sudo gem install nokogiri
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/gem:4: warning: Insecure world writable dir /Users in PATH, mode 040777
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/patelc75/.rvm/rubies/ruby-1.8.7-p334/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.
Before installing nokogiri gem, you need to get libraries installed.
Here are the steps to do it with homebrew
# the rest of this snippet assumes installation of libxml 2.7.7. YMMV.
brew install libxml2
brew link libxml2
# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 \
--with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
make
sudo make install
gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
With macports
sudo port install libxml2 libxslt
sudo gem install nokogiri
More information here http://nokogiri.org/tutorials/installing_nokogiri.html
I tries all kinds of solutions I can found, including:
. use brew to install libxslt / libxml2 / libiconv
. tries to gem install with various --with-configurations
sadly, they all didn't work for me, until I uninstalled MacPort and all installed ports.
Then simply executed command gem install nokogiri, the gem and rdoc got installed like a breeze.
I don't understand the very details of why, but according to my own experiences of using MacPort (resulted in multiple sets of ruby/rake/gem(s) installed) and articles comparing brew and port, I will not go back to port.

Resources