安装RedCloth(4.2.7)时发生错误,Bundler无法继续

时间:2015-11-05 21:13:08

标签: ruby-on-rails ruby heroku rvm redcloth

我在Heroku Bamboo堆栈上有一个应用程序,并且已按照此处的说明(https://devcenter.heroku.com/articles/cedar-migration)迁移到Cedar堆栈。

我的应用程序有一个旧版本的RefineryCMS(1.0.3),我试图避免在那里处理升级(现在),所以我保持Rails为3.0.9。但是,Ruby 1.8.7已经过了EOL,所以我至少需要升级它。我在我的Gemfile中指定了1.9.3,因此:

  

来源“https://rubygems.org
  红宝石“1.9.3”

然后我尝试bundle install。这是我尝试的输出:

Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies....
Using rake 0.8.7
Installing RedCloth 4.2.7 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/day/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20151105-14593-x80q4a.rb extconf.rb
checking for main() in -lc... no
creating Makefile

make  clean

make
compiling redcloth_attributes.c
ragel/redcloth_attributes.c.rl: In function 'redcloth_attribute_parser':
ragel/redcloth_attributes.c.rl:26:11: error: variable 'act' set but not used [-Werror=unused-but-set-variable]
ragel/redcloth_attributes.c.rl: In function 'redcloth_attributes':
ragel/redcloth_attributes.c.rl:45:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
ragel/redcloth_attributes.c.rl: In function 'redcloth_link_attributes':
ragel/redcloth_attributes.c.rl:54:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
cc1: all warnings being treated as errors
make: *** [redcloth_attributes.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/day/.rvm/gems/ruby-1.9.3-p551/gems/RedCloth-4.2.7 for inspection.
Results logged to /Users/day/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-darwin-14/1.9.1/RedCloth-4.2.7/gem_make.out
An error occurred while installing RedCloth (4.2.7), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.7'` succeeds before bundling.

毋庸置疑gem install RedCloth -v '4.2.7'导致同样的错误。

我发现了这个问题Failed to build gem native extension when install RedCloth-4.2.9 install Linux,然而,我的问题是RedCloth 4.2.7(不是4.2.9),我正在运行OSX Yosemite(不是Linux)。那里有一个与OSX Mountain Lion有关的答案,我觉得值得一试:

rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install

显然,为了我的目的,我将1.9.2更改为1.9.3,并省略了--no-ri --no-rdoc标记。可悲的是,bundle install继续失败并出现同样的错误。

继续我的在线搜索,我发现了这篇文章Install RedCloth 4.2.7 gem with bundler (using ruby enterprise edition 1.8.7)。没有被版本不匹配所扰乱(再次,我使用Ruby 1.9.3,而不是1.8.7),我决定尝试我在那里找到的建议,即:

bundle config build.RedCloth --with-cflags=-w
bundle install

这次,快乐哦!有效!而且我接下来的事情。我想我会在这里与其他任何发现自己陷入困境的人分享这个小小的旅程。干杯!

1 个答案:

答案 0 :(得分:2)

我能够通过为构建RedCloth时应用的Bundler额外构建选项来解决此问题,如下所示:

bundle config build.RedCloth --with-cflags=-w
bundle install