rbenv没有正确设置ruby版本

时间:2013-07-25 01:06:58

标签: ruby rbenv

我成功安装了rbenv,这看起来是正确的:

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

但是当我运行bundle时,它会以某种方式使用系统ruby?

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.

有人可以帮忙吗?

4 个答案:

答案 0 :(得分:1)

确保安装并选择要使用的Ruby版本; rbenv默认为系统一,即使您已使用rbenv install添加另一个。

要查看要使用哪个Ruby rbenv,只需运行rbenv version

有关如何在不同上下文中设置Ruby版本的详细信息,请参阅rbenv localrbenv globalrbenv shell

答案 1 :(得分:0)

Emil Sit,问题是不知何故freetds尝试使用系统ruby,即使rbenv配置正确。在构建原生扩展时会传递--ruby标志:

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.

答案 2 :(得分:0)

确保在使用rbenv rehash安装捆绑包后运行gem install bundler

答案 3 :(得分:0)

解决方案是从/ usr / local / bundle中删除系统提供的bundler,因为它已过时且运行不正常。使用我的新ruby(通过rbenv)和bundler(通过新的ruby),我能够正确编译所有内容。