rbenv not setting the ruby version correctly - ruby

I installed rbenv successfully and this appears correct:
piousboxs-MacBook-Pro:lms piousbox$ cat .rbenv-version
1.8.7-p374
piousboxs-MacBook-Pro:lms piousbox$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin12.2.1]
piousboxs-MacBook-Pro:lms piousbox$ which ruby
/Users/piousbox/.rbenv/shims/ruby
But when I run bundle, it uses the system ruby somehow?
Installing tiny_tds (0.5.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... 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.
Can anyone help?

Make sure you install and select a version of Ruby to use; rbenv defaults to the system one, even if you've used rbenv install to add another.
To see which Ruby rbenv is going to use, just run rbenv version.
See rbenv local or rbenv global or rbenv shell for details on how to set the version of Ruby in different contexts.

Emil Sit, the problem is that somehow freetds tries to use the system ruby, even though rbenv is configured correctly. There is this --ruby flag being passed when building native extensions:
Installing tiny_tds (0.5.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --ruby=/Users/piousbox/.rbenv/shims/ruby
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.
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/1.8/usr/bin/ruby
--enable-lookup
--disable-lookup
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-freetds-dir
--without-freetds-dir
--with-freetds-include
--without-freetds-include=${freetds-dir}/include
--with-freetds-lib
--without-freetds-lib=${freetds-dir}/lib
--with-iconvlib
--without-iconvlib
--with-sybdblib
--without-sybdblib
Gem files will remain installed in /Users/piousbox/.bundler/tmp/26769/gems/tiny_tds-0.5.1 for inspection.
Results logged to /Users/piousbox/.bundler/tmp/26769/gems/tiny_tds-0.5.1/ext/tiny_tds/gem_make.out
An error occurred while installing tiny_tds (0.5.1), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '0.5.1'` succeeds before bundling.

Make sure you've run rbenv rehash after installing bundler with gem install bundler.

The solution was to remove the system-provided bundler from /usr/local/bundle, as it is outdated and does not run very well. With my new ruby (via rbenv) and bundler (via new ruby) I was able to compile everything correctly.

Related

windows ruby install jsduck error

I am trying to install jsduck on ruby gem, however I got error.
I've downloaded Ruby 2.3.0(x64).
I've also downloaded DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe which is for x64.
I installed the ruby 2.3.0(x64). Then I extracted devkit to "C:/rubydevkit"
I ran the below commands in "C:/rubydevkit" folder :
$ruby dk.rb init
and
$ruby dk.rb install
So far, everything is okay. I installed sass successfully by
$gem install sass
However, when I try
$gem install jsduck
or
$gem install rdiscount --platform=ruby
I got followin error:
$ gem install jsduck
ERROR: Error installing jsduck:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rdiscount-2.1.8/ext
C:/Ruby23-x64/bin/ruby.exe -r ./siteconf20160411-6020-6ayo32.rb extconf.rb
checking for random()... no
checking for srandom()... no
checking for rand()... yes
checking for srand()... yes
checking size of unsigned long... 4
checking size of unsigned int... failed
checking size of unsigned short... 2
no int with size 2
*** 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:/Ruby23-x64/bin/$(RUBY_BASE_NAME)
--with-rdiscount-dir
--without-rdiscount-dir
--with-rdiscount-include
--without-rdiscount-include=${rdiscount-dir}/include
--with-rdiscount-lib
--without-rdiscount-lib=${rdiscount-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/rdiscount-2.1.8/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rdiscount-2.1.8 for inspection.
Results logged to C:/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/rdiscount-2.1.8/gem_make.out
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Below are my current versions versions:
Windows 8.1 64bit
$ gem -v
2.5.1
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
Have you tried using a precompiled windows binary?
You're really running into issues with compiling binary extensions for Ruby. Specifically the rdiscount dependency is failing to compile - you might get better help from rdiscount developers.
RDiscount definitely works on Ruby 2.2.2 on Windows (since this is covered by CI) and in Ruby 2.3.0 on Linux (since this is also covered by CI).
But RDiscount + Ruby 2.3.0 + Windows hasn't been tested yet.
See if you can build successfully with Ruby 2.2.2 on your Windows box.

Unable to install tiny_tds on Mac OS X Yosemite v10.10.2

I am using RubyMine IDE on MAC OS X yosemite. On trying to install tiny_tds its giving the following error
sudo gem install tiny_tds -v '0.6.2'
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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.
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.0/usr/bin/ruby
--enable-lookup
--disable-lookup
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/
--with-freetds-dir
--without-freetds-dir
--with-freetds-include
--without-freetds-include=${freetds-dir}/include
--with-freetds-lib
--without-freetds-lib=${freetds-dir}/
--with-iconvlib
--without-iconvlib
--with-sybdblib
--without-sybdblib
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2/ext/tiny_tds/gem_make.out
I have installed freetds
brew install freetds
and I can see it when I do brew list
but again when I do sudo gem install tiny_tds , it gives me error as freetds missing.
Please help.
Thanks
Did gem install tiny_tds not work?
FYI - Using sudo with gem install is not best practice.
As I posted at Homebrew / TinyTDS / FreeTDS bundle error, in addition to brew install freetds, you may also need to tell the gem where to find freetds.
If you are using bundler, you can do that by configuring bundler.
For example (depending where exactly homebrew installed freetds):
bundle config set --global build.tiny_tds --with-freetds-dir=/opt/homebrew/Cellar/freetds/1.3.3

Mac, Rails 4: install `tiny_tds` gem with `freetds`

We're using activerecord-sqlserver-adapter adapter for Rails 4 to talk to a SQL Server DB. This adapter requires the tiny_tds gem. In order to install tiny_tds, you need freetds installed on your system because it's used during the compiling for the gem.
On my system I have installed RVM and homebrew. I have brew install freetds and confirmed that it works by tsql -C and have actually connected to the SQL Server. From my understanding, that means freetds is "installed" on my machine and works.
However, everytime I do a gem install tiny_tds if complains about freetds is missing
I have tried several of the parameter options to "link" to the proper files, but nothing seems to work for me. I've already spent several hours googling and looking over the gem author's writings. Some other developers I'm working with have this functioning, but I'm setting up a new environment and for some reason can't get it working. They've already looked into it as well and are not sure what the issue is.
It seems that the installation of the tiny_tds gem just doesn't know that freetds is actually installed on the system.
On a sidenote, I've also looked at mini_portile and it didn't work properly either...since I've already spent several hours down the current path, I want to figure this out before I switch over to investigating mini_portile.
Here's the output of the install:
$ gem install tiny_tds
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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.
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.0/usr/bin/ruby
--enable-lookup
--disable-lookup
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/
--with-freetds-dir
--without-freetds-dir
--with-freetds-include
--without-freetds-include=${freetds-dir}/include
--with-freetds-lib
--without-freetds-lib=${freetds-dir}/
--with-iconvlib
--without-iconvlib
--with-sybdblib
--without-sybdblib
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2/ext/tiny_tds/gem_make.out
Finally resolved this. Forgot to install Ruby via RVM after I installed RVM, and this was causing all the issues.
If you get weird errors similar to the above, do a rvm list to see if you even have any Rubies installed, and then do a which ruby on your terminal (Mac) to see if you are indeed using the RVM Ruby.
You can pass the location of the freetds lib to the gem command like this:
gem install tiny_tds -- --with-freetds-dir=/opt/homebrew/Cellar/freetds/1.2.21

Gem install pg works but bundle install fails

There is very lot of topics about this but I already try almost all of them with no success.
I'm on Mac OS X 10.9.4 Mavericks, I have the Postgres.app, and it seams to work fine, sudo gem install pg works too :
Building native extensions. This could take a while...
Successfully installed pg-0.17.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.17.1
Done installing documentation for pg after 2 seconds
1 gem installed
but when I try to bundle install I have the same error than every one else.
I already try bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
then bundle install
I have the Xcode Command Line Tools.
which psqlreturn /Applications/Postgres.app/Contents/Versions/9.3/bin/psql
which postgresreturn /Applications/Postgres.app/Contents/Versions/9.3/bin/postgres
Here is the error for bundle install:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.0/usr/bin/ruby
--with-pg
--without-pg
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
extconf failed, exit code 1
Gem files will remain installed in /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
After days I finally found the problem source (ironically when I decide to give up, and move on).
When I do a
which bundle and which gem
They were not from the same ruby installation.
bundle was from rbenv and gem from the preinstalled ruby on mac osx.
might have the permission issue. can use:
sudo bundle install --without nothing --path vendor/cache

RVM + Ruby 1.9.2 + Rmagick + Lion = System Works, RVM Doesn't

I've installed Ruby 1.9.2 through RVM on a fresh install of OS X Lion. I have installed ghostscript and imagemagick through homebrew, and when running gem install rmagick using RVM, it fails. When using gem install rmagick on the system install of ruby, it works just fine.
This is the error that is produced:
─wedtm#WedHQ ~/.rvm/gems/ruby-1.9.2-p290/cache ‹ruby-1.8.7›
╰─$ gem install rmagick 1 ↵
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/wedtm/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.13.1. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
*** 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/wedtm/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
--with-MagickCorelib
--without-MagickCorelib
--with-Magicklib
--without-Magicklib
--with-Magick++lib
--without-Magick++lib
Gem files will remain installed in /Users/wedtm/.rvm/gems/ruby-1.8.7-p352/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/wedtm/.rvm/gems/ruby-1.8.7-p352/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
What could be causing this? Any ideas on how to get RVM to see the imagemagick like it's should?
The magick-installer script ( https://github.com/maddox/magick-installer ) does a fantastic job of installing ImageMagick on the mac. When I installed without using this script, the install would appear to succeed but the gem would never find the installation.
Using this script, I succeeded with installation where I had failed many times previously. Good luck :)

Resources