在我的Mac OSX 10.6.8上使用Rails应用程序并遗漏了一些软件

时间:2015-03-29 03:58:51

标签: ruby-on-rails ruby rvm clang

我正在关注this guide作为网络开发课程的一部分,所以我相信我会完全理解每个部分后来会做什么,但是现在我只是在做它所说的和计算基于我所知道的一切,我能做到的一切。前一章(创建应用程序)取得了成功,但现在我偶然发现this instruction。我无法编辑该行,因为它不存在。这是Gemfile,如TextEdit中所示:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

应用程序运行良好,服务器运行良好(虽然它不必为此运行所以我想这不是所有相关的)。指南很可能有问题,但它是什么?现在建立这个有什么意义吗,或者当我对Rails有更多的了解时,我应该继续学习并重新学习它吗?

编辑:我在Gemfile末尾添加了行并运行bundle install(感谢@Antarr Byrd!)但是收到了错误消息。我发布整个日志以防万一:

Mac-2:test_app mac$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies.............
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.1
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.0
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.3
Using activejob 4.2.1
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1
Using activerecord-jdbc-adapter 1.3.15
Using jdbc-sqlite3 3.8.7
Using activerecord-jdbcsqlite3-adapter 1.3.15
Using bundler 1.9.1
Using coffee-script-source 1.9.1
Using execjs 2.4.0
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.2.1
Using coffee-rails 4.1.0
Using hike 1.2.3
Using multi_json 1.11.0
Using jbuilder 2.2.12
Using jquery-rails 4.0.3

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

    /Users/mac/.rvm/rubies/jruby-1.7.19/bin/jruby -r ./siteconf20150329-367-1xqntht.rb extconf.rb 
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS.

   (root) at /Users/mac/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/mkmf.rb:8
  require at org/jruby/RubyKernel.java:1071
   (root) at /Users/mac/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
   (root) at extconf.rb:2

extconf failed, uncaught signal 1

Gem files will remain installed in /Users/mac/.rvm/gems/jruby-1.7.19/gems/pg-0.18.1 for inspection.
Results logged to /Users/mac/.rvm/gems/jruby-1.7.19/extensions/universal-java-1.6/1.9/pg-0.18.1/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.

gem install pg -v '0.18.1'也给了我麻烦。

Mac-2:test_app mac$ gem install pg -v '0.18.1'
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/mac/.rvm/rubies/jruby-1.7.19/bin/jruby -r ./siteconf20150329-383-1d9a2xw.rb extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS.

   (root) at /Users/mac/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/mkmf.rb:8
  require at org/jruby/RubyKernel.java:1071
   (root) at /Users/mac/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
   (root) at extconf.rb:2

extconf failed, uncaught signal 1

Gem files will remain installed in /Users/mac/.rvm/gems/jruby-1.7.19/gems/pg-0.18.1 for inspection.
Results logged to /Users/mac/.rvm/gems/jruby-1.7.19/extensions/universal-java-1.6/1.9/pg-0.18.1/gem_make.out

我对这些错误消息感到难过。如果有人能够解释至少发生了什么以及如何修复它的基础知识我会非常感激。

编辑2:我尝试将Ruby更新为2.2,它说我需要clang 3.0或更高版本,我确实有。这是我今天早些时候尝试安装Python 3时遇到的问题,我仍然无法弄清楚我做错了什么。

Mac-2:~ mac$ rvm install 2.2
ruby-2.2.0 - #removing src/ruby-2.2.0..
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.6/i386/ruby-2.2.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx_brew.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/mac/.rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)...
ruby-2.2.0 - #downloading ruby-2.2.0, this may take a while depending on your connection...
ruby-2.2.0 - #extracting ruby-2.2.0 to /Users/mac/.rvm/src/ruby-2.2.0....
ruby-2.2.0 - #applying patch /Users/mac/.rvm/patches/ruby/2.2.0/fix_installing_bundled_gems.patch.
ruby-2.2.0 - #configuring.
Error running './configure --prefix=/Users/mac/.rvm/rubies/ruby-2.2.0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl --disable-install-doc --enable-shared',
showing last 15 lines of /Users/mac/.rvm/log/1427607081_ruby-2.2.0/configure.log
[2015-03-29 02:31:46] ./configure
current path: /Users/mac/.rvm/src/ruby-2.2.0
GEM_HOME=/Users/mac/.rvm/gems/jruby-1.7.19
PATH=/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Users/mac/.rvm/gems/jruby-1.7.19/bin:/Users/mac/.rvm/gems/jruby-1.7.19@global/bin:/Users/mac/.rvm/rubies/jruby-1.7.19/bin:/usr/local/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/X11/bin:/Users/mac/.rvm/bin
GEM_PATH=/Users/mac/.rvm/gems/jruby-1.7.19:/Users/mac/.rvm/gems/jruby-1.7.19@global
command(5): ./configure --prefix=/Users/mac/.rvm/rubies/ruby-2.2.0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl --disable-install-doc --enable-shared
config.guess already exists
config.sub already exists
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
i686-apple-darwin10-gcc-4.2.1: error trying to exec 'cc1': execvp: No such file or directory
configure: error: clang version 3.0 or later is required
There has been an error while running configure. Halting the installation.
Mac-2:~ mac$ ruby -v
jruby 1.7.19 (1.9.3p551) 2015-01-29 20786bd on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-10M4609 +jit [darwin-x86_64]
Mac-2:~ mac$ which clang
/usr/bin/clang
Mac-2:~ mac$ clang -v
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.8.0
Thread model: posix

编辑3:修复它而无需更新LLVM或Clang或其他任何内容。我只需要摆脱jruby而不是使用Ruby 2.2。

Mac-2:rubies mac$ rm -rf jruby-1.7.19/
Mac-2:rubies mac$ brew install ruby
Mac-2:test_app mac$ gem install pg -v '0.18.1'
Mac-2:test_app mac$ bundle install

即使我与Heroku本身有一些问题,但这也很成功,所以我接受了Antarr Byrd的回答。

3 个答案:

答案 0 :(得分:2)

只需将其添加到Gemfile并执行bundle install

即可
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

答案 1 :(得分:0)

一些注释/问题/想法:

1)您的问题主题暗示这与Heroku有关,但您的所有日志/输出都来自您当地的Mac。应编辑以反映未来的求职者

2)你正在使用JRuby 1.7运行,这对于第一个应用程序来说有点奇怪。看看你说你正在关注的Railsbridge文档,他们让你使用Ruby 2.2,这是一个更常见的平台。我会按照他们的指南中的Step 7跟随RVM安装2.2,然后再试一次。

答案 2 :(得分:-2)

如果您的数据库是sqlite,那么您需要添加

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

如果是mysql,只需用gem'mysql2'

替换gem'sqlite3'