<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>programmingworld (WJFYY)</title>
    <link>https://ruby-china.org/programmingworld</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>Rvm 安装的 ruby，在 Gemfile 里找不到 rake</title>
      <description>&lt;p&gt;rvm 安装 ruby2.1.5，并将其设置为默认版本
此时默认的 rake gem 包的版本是 10.1.0&lt;/p&gt;

&lt;p&gt;然后 gem install 需要的 gem，这些 gem 都被安装在 rvm 的 gems 目录中，如：/Users/wjf/.rvm/gems/ruby-2.1.5/gems，这都一切正常。
然后在 RubyMine 中设置“Ruby SDK and Gems” ，如：
&lt;img src="https://l.ruby-china.com/photo/2014/4cca3ffb0f49def1bbc99e1edd68d6f6.png" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;并在 Gemfile 中设置需要的 gem:
gem 'rake'
gem 'sinatra'
gem '...'&lt;/p&gt;

&lt;p&gt;除了 rake 以外的其它 gem 都没问题，而对应 rake 会报：Gem 'rake' is not available in SDK 'Rvm:ruby-2.1.5'&lt;/p&gt;

&lt;p&gt;我发现对于这个问题的表面现象是，所有通过 gem install 的 gem 包它们的目录都在如前所述的 .rvm/gems/ruby-2.1.5/gems下，这些gem包在Gemfile中引用是正常的，而rake是安装ruby时的默认gem包，其路径不在 .rvm/gems/ruby-2.1.5/gems下，其在gemfile中直接引用就会not available.&lt;/p&gt;

&lt;p&gt;后来我又 gem install rake 了一个新版本：10.4.2，该 gem 包在 .rvm/gems/ruby-2.1.5/gems目录中，然后我在Gemfile中 指定 rake 的版本：gem 'rake','~&amp;gt; 10.4.2'  问题解决。&lt;/p&gt;

&lt;p&gt;可是疑问仍然在：为什么不能直接引用 通过 rvm 安装的 ruby 中的默认 rake？请大神解惑！！！&lt;/p&gt;</description>
      <author>programmingworld</author>
      <pubDate>Sun, 07 Dec 2014 11:29:38 +0800</pubDate>
      <link>https://ruby-china.org/topics/23064</link>
      <guid>https://ruby-china.org/topics/23064</guid>
    </item>
    <item>
      <title>如何在不安装 mysql 数据库的情况下安装 mysql2gem 包</title>
      <description>&lt;p&gt;环境大概是这样的：
max os 10.10.
rvm 1.26.3
使用 rvm 安装的 ruby 2.1.5&lt;/p&gt;

&lt;p&gt;然后我想安装 mysql2gem 包：
gem install mysql2&lt;/p&gt;

&lt;p&gt;报以下错误：
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.&lt;/p&gt;

&lt;p&gt;/Users/wjf/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20141206-1263-1pbvydq.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.&lt;/p&gt;

&lt;p&gt;Provided configuration options:
    --with-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/wjf/.rvm/rubies/ruby-2.1.5/bin/ruby
    --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
    --without-mysql-config
    --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-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib&lt;/p&gt;

&lt;p&gt;extconf failed, exit code 1&lt;/p&gt;

&lt;p&gt;Gem files will remain installed in /Users/wjf/.rvm/gems/ruby-2.1.5/gems/mysql2-0.3.17 for inspection.
Results logged to /Users/wjf/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0/mysql2-0.3.17/gem_make.out
wjfdeMBP:~ wjf$ rvm -v
Warning! PATH is not properly set up, '/Users/wjf/.rvm/gems/ruby-2.1.5/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.1.5'.&lt;/p&gt;

&lt;p&gt;以上错误在 windows/linux 平台上安装 mysql2gem 包的时候也很常见，网上的大部分解决方法都是安装 mysql 数据库及相关的 package，我在 linux 上就是这么解决的，但是现在&lt;strong&gt;在 mac 上我不想安装 mysql 数据库，就想搞定这个问题该怎么办？&lt;/strong&gt;
我在 mysql2 在 github 的主页上看到这样一段：
This gem links against MySQL's libmysqlclient C shared library. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.&lt;/p&gt;

&lt;p&gt;于是我开始尝试安装那两个 package，可是都安装失败，网上搜了半天也没有合适的方法，特来此求救！&lt;/p&gt;</description>
      <author>programmingworld</author>
      <pubDate>Sat, 06 Dec 2014 22:29:02 +0800</pubDate>
      <link>https://ruby-china.org/topics/23061</link>
      <guid>https://ruby-china.org/topics/23061</guid>
    </item>
    <item>
      <title>Sinatra 结合 ActiveModel 使用时数据库迁移文件如何生成</title>
      <description>&lt;p&gt;在 Rails 项目中通过 rails 命令生成目录结构，以及相应的 db/migrate 脚本文件，那如果使用 sinatra 呢？这些数据库迁移文件该如何生成？&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;仿照 rails 项目手工创建相应文件？
 这样做很没人性啊&lt;/li&gt;
&lt;li&gt;创建 rails 项目，然后在目录结构中修改？或者使用 rails 命令？
没这个必要吧&lt;/li&gt;
&lt;li&gt; 请大神赐教！！！&lt;/li&gt;
&lt;/ol&gt;</description>
      <author>programmingworld</author>
      <pubDate>Tue, 02 Dec 2014 22:35:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/22985</link>
      <guid>https://ruby-china.org/topics/22985</guid>
    </item>
    <item>
      <title>使用 ruby 构建 Rest service 的讨论</title>
      <description>&lt;p&gt;之前在网上看一篇关于用 Sinatra + Datamapper 构建 rest service 的示例：
&lt;a href="http://www.codeproject.com/Tips/668655/Rest-Service-with-Ruby-plus-Sinatra-plus-Datamappe" rel="nofollow" target="_blank"&gt;http://www.codeproject.com/Tips/668655/Rest-Service-with-Ruby-plus-Sinatra-plus-Datamappe&lt;/a&gt;
看完之后觉得很受用，同时也想请圈中大神分享一下关于构建 rest service 的一些实战经验，包括 使用的技术，框架，组件等方方面面，以给我们新手涨点姿势～～～&lt;/p&gt;</description>
      <author>programmingworld</author>
      <pubDate>Sun, 30 Nov 2014 15:17:55 +0800</pubDate>
      <link>https://ruby-china.org/topics/22940</link>
      <guid>https://ruby-china.org/topics/22940</guid>
    </item>
    <item>
      <title>RVM 安装 Ruby2.1.5 出现的问题</title>
      <description>&lt;p&gt;按照 Ruby-China  wiki《如何快速正确的安装 Ruby, Rails 运行环境》上的步骤用 rvm 安装 ruby&lt;/p&gt;

&lt;p&gt;MacOS 10.10.1 
Xcode 6.1
Homebrew: 0.9.5
Rvm:
rvm 1.26.3 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [&lt;a href="https://rvm.io/" rel="nofollow" target="_blank"&gt;https://rvm.io/&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;步骤 1:
rvm install 2.1.5
输出如下信息：
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.1.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system..........
Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl......
Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl',
showing last 15 lines of /Users/wjf/.rvm/log/1417267175_ruby-2.1.5/package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libksba_openssl.log
++ case "$1" in
++ [[ -t 1 ]]
++ return 1
++ printf %b 'There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try &lt;code&gt;brew tap --repair&lt;/code&gt; and make sure &lt;code&gt;brew doctor&lt;/code&gt; looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installationn" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installationn&lt;/a&gt;\'
There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try &lt;code&gt;brew tap --repair&lt;/code&gt; and make sure &lt;code&gt;brew doctor&lt;/code&gt; looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installation" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installation&lt;/a&gt;
++ case "$_system_version" in
++ return 1
Requirements installation failed with status: 1.
wjfdeMBP:~ wjf$ brew tap --repair
Pruned 0 dead formulae&lt;/p&gt;

&lt;p&gt;步骤 2:
根据上述信息查看了日志文件 package_install_autoconf_automake_libtool_pkg-config_libyaml_readline_libksba_openssl.log
内容如下：
[2014-11-29 21:29:08] requirements_osx_brew_libs_install
requirements_osx_brew_libs_install ()
{
    brew unlink "$@" || true;
    brew install "$@" || {
        typeset ret=$?;
        rvm_warn "There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try `brew tap --repair` and make sure `brew doctor` looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installation" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installation&lt;/a&gt;";
        case "$_system_version" in
            10.6)
                rvm_warn "
On OSX 10.6 instead of command line tools install:
    &lt;a href="https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg" rel="nofollow" target="_blank"&gt;https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg&lt;/a&gt;"
            ;;
        esac;
        return $ret
    }
}
current path: /Users/wjf
PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/wjf/.rvm/bin:
command(9): requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libksba openssl
++ brew unlink autoconf automake libtool pkg-config libyaml readline libksba openssl
Error: No such keg: /usr/local/Cellar/autoconf
++ true
++ brew install autoconf automake libtool pkg-config libyaml readline libksba openssl
==&amp;gt; Downloading &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.69.yosemite.bottle.1.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.69.yosemite.bottle.1.tar.gz&lt;/a&gt;
==&amp;gt; Pouring autoconf-2.69.yosemite.bottle.1.tar.gz
&lt;img title=":beer:" alt="🍺" src="https://twemoji.ruby-china.com/2/svg/1f37a.svg" class="twemoji"&gt;  /usr/local/Cellar/autoconf/2.69: 70 files, 3.1M
==&amp;gt; Downloading &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/automake-1.14.1.yosemite.bottle.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/automake-1.14.1.yosemite.bottle.tar.gz&lt;/a&gt;
Error: Failed to download resource "automake"
Download failed: &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/automake-1.14.1.yosemite.bottle.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/automake-1.14.1.yosemite.bottle.tar.gz&lt;/a&gt;
Warning: Bottle installation failed: building from source.
==&amp;gt; Downloading &lt;a href="http://ftpmirror.gnu.org/automake/automake-1.14.1.tar.gz" rel="nofollow" target="_blank"&gt;http://ftpmirror.gnu.org/automake/automake-1.14.1.tar.gz&lt;/a&gt;
Trying a mirror...
==&amp;gt; Downloading &lt;a href="http://ftp.gnu.org/gnu/automake/automake-1.14.1.tar.gz" rel="nofollow" target="_blank"&gt;http://ftp.gnu.org/gnu/automake/automake-1.14.1.tar.gz&lt;/a&gt;
==&amp;gt; ./configure --prefix=/usr/local/Cellar/automake/1.14.1
==&amp;gt; make install
&lt;img title=":beer:" alt="🍺" src="https://twemoji.ruby-china.com/2/svg/1f37a.svg" class="twemoji"&gt;  /usr/local/Cellar/automake/1.14.1: 131 files, 3.2M, built in 12.7 minutes
==&amp;gt; Downloading &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/libtool-2.4.2.yosemite.bottle.3.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/libtool-2.4.2.yosemite.bottle.3.tar.gz&lt;/a&gt;
==&amp;gt; Pouring libtool-2.4.2.yosemite.bottle.3.tar.gz
==&amp;gt; Caveats
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==&amp;gt; Summary
&lt;img title=":beer:" alt="🍺" src="https://twemoji.ruby-china.com/2/svg/1f37a.svg" class="twemoji"&gt;  /usr/local/Cellar/libtool/2.4.2: 69 files, 2.5M
==&amp;gt; Downloading &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.yosemite.bottle.2.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.yosemite.bottle.2.tar.gz&lt;/a&gt;
Error: Failed to download resource "pkg-config"
Download failed: &lt;a href="https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.yosemite.bottle.2.tar.gz" rel="nofollow" target="_blank"&gt;https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.yosemite.bottle.2.tar.gz&lt;/a&gt;
Warning: Bottle installation failed: building from source.
==&amp;gt; Downloading &lt;a href="http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" rel="nofollow" target="_blank"&gt;http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz&lt;/a&gt;
Trying a mirror...
==&amp;gt; Downloading &lt;a href="http://fossies.org/linux/misc/pkg-config-0.28.tar.gz" rel="nofollow" target="_blank"&gt;http://fossies.org/linux/misc/pkg-config-0.28.tar.gz&lt;/a&gt;
Error: Failed to download resource "pkg-config"
Download failed: &lt;a href="http://fossies.org/linux/misc/pkg-config-0.28.tar.gz" rel="nofollow" target="_blank"&gt;http://fossies.org/linux/misc/pkg-config-0.28.tar.gz&lt;/a&gt;
++ typeset ret=1
++ rvm_warn 'There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try &lt;code&gt;brew tap --repair&lt;/code&gt; and make sure &lt;code&gt;brew doctor&lt;/code&gt; looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installation" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installation&lt;/a&gt;'
++ rvm_pretty_print stdout
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 1 ]]
++ return 1
++ printf %b 'There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try &lt;code&gt;brew tap --repair&lt;/code&gt; and make sure &lt;code&gt;brew doctor&lt;/code&gt; looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installationn" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installationn&lt;/a&gt;\'
There were package installation errors, make sure to read the log.&lt;/p&gt;

&lt;p&gt;Try &lt;code&gt;brew tap --repair&lt;/code&gt; and make sure &lt;code&gt;brew doctor&lt;/code&gt; looks reasonable.&lt;/p&gt;

&lt;p&gt;Check Homebrew requirements &lt;a href="https://github.com/Homebrew/homebrew/wiki/Installation" rel="nofollow" target="_blank"&gt;https://github.com/Homebrew/homebrew/wiki/Installation&lt;/a&gt;
++ case "$_system_version" in
++ return 1&lt;/p&gt;

&lt;p&gt;根据上面日志看，rvm 在开始下载 autoconf,automake,libtool 时都有出错，但进行了重试后成功了，
但是到了下载 pkg-config 时彻底失败了。&lt;/p&gt;

&lt;p&gt;在网上找了半天也没找到解决方法，后来想用 rvm 安装其它 ruby 版本或者使用 rbenv，但是这个问题毕竟还是没搞清楚，不想放弃，望各位大神指点啊！&lt;/p&gt;</description>
      <author>programmingworld</author>
      <pubDate>Sat, 29 Nov 2014 23:14:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/22932</link>
      <guid>https://ruby-china.org/topics/22932</guid>
    </item>
    <item>
      <title>关于 Ruby 开发工具</title>
      <description>&lt;p&gt;请问在 MacOS 和 Linux 下最好用的 Ruby 开发工具是什么？各位大神推荐一下！&lt;/p&gt;</description>
      <author>programmingworld</author>
      <pubDate>Sat, 22 Nov 2014 23:15:51 +0800</pubDate>
      <link>https://ruby-china.org/topics/22815</link>
      <guid>https://ruby-china.org/topics/22815</guid>
    </item>
  </channel>
</rss>
