熱門文章

顯示具有 gem 標籤的文章。 顯示所有文章
顯示具有 gem 標籤的文章。 顯示所有文章

2016年9月27日 星期二

[Rails]error occurred while installing json (1.8.1)


Error Logs

Installing json 1.8.1 with native extensions

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

    current directory: /usr/local/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
/usr/local/opt/ruby/bin/ruby -r ./siteconf20160927-76871-1q35230.rb extconf.rb
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                              ^
/usr/local/Cellar/ruby/2.3.1/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ (    \
        ^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
          ^        ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.3.0/gems/json-1.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0/json-1.8.1/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.


解決方法: 來源

# Remove user-specific gems and git repos
rm -rf ~/.bundle/ ~/.gem/bundler/ ~/.gems/cache/bundler/

# Remove system-wide git repos and git checkouts
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/

# Remove project-specific settings
rm -rf .bundle/

# Remove project-specific cached gems and repos
rm -rf vendor/cache/

# Remove the saved resolve of the Gemfile
rm -rf Gemfile.lock

# Uninstall the rubygems-bundler and open_gem gems
rvm gemset use global # if using rvm
gem uninstall rubygems-bundler open_gem

# Try to install one more time
bundle install

一次貼到command line :
rm -rf ~/.bundle/ ~/.gem/bundler/ ~/.gems/cache/bundler/
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/rm -rf .bundle/
rm -rf vendor/cache/
rm -rf Gemfile.lock
bundle install



2016年9月23日 星期五

[Rails]simple_form 錯誤 error -undefined method 'number?'


undefined method 'number?' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x007fd89fda3d40>





解決方法>> 更改你的Gemfile


gem 'simple_form'

to

gem 'simple_form', github: 'kesha-antonov/simple_form', branch: 'rails-5-0'




然後bundle install,重開server  Done

2016年9月19日 星期一

[Rails]錯誤解決-gem 'pg' 安裝PostgreSQL -way2

之前也有一篇解決方法 [Rails]錯誤解決-gem 'pg' 安裝PostgreSQL

後來也看到這個,Heroku 的 PostgreSQL 軟體相依。


更新資料庫

首先,需要讓資料庫在 Heroku 跑起來。Heroku 使用不同於 Rails 預設的資料庫。請修改 Gemfile 的內容:
請將

gem 'sqlite3'

改為

group :development do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

執行 bundle install --without production 命令來解決軟體相依問題。

2016年7月13日 星期三

[Ruby]Getting a “bad interpreter” error when using brew

http://stackoverflow.com/questions/8864668/getting-a-bad-interpreter-error-when-using-brew

原本都使用正常,但是在安裝 homebrew 之後造成錯誤




嘗試重新安裝 ruby

➜  ~ git:(master) brew install ruby
==> Installing dependencies for ruby: readline, libyaml, openssl
==> Installing ruby dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-6.3.8.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.


Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
🍺  /usr/local/Cellar/readline/6.3.8: 46 files, 2.0M
==> Installing ruby dependency: libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.g
######################################################################## 100.0%
==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
==> Installing ruby dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h_1.el_capitan.bottle.tar.
######################################################################## 100.0%
==> Pouring openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2h_1: 1,691 files, 12M
==> Installing ruby
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.3.1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.3.1.el_capitan.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/rake
Target /usr/local/bin/rake
already exists. You may want to remove it:
  rm '/usr/local/bin/rake'

To force the link and overwrite all conflicting files:
  brew link --overwrite ruby

To list all files that would be deleted:
  brew link --overwrite --dry-run ruby

Possible conflicting files are:
/usr/local/bin/rake
/usr/local/bin/rdoc
/usr/local/bin/ri
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby
==> Summary
🍺  /usr/local/Cellar/ruby/2.3.1: 1,260 files, 19.0M
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master)  
➜  ~ git:(master) rm '/usr/local/bin/rake'
➜  ~ git:(master)   brew link --overwrite ruby
Linking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks created
➜  ~ git:(master) brew link --overwrite --dry-run ruby
Warning: Already linked: /usr/local/Cellar/ruby/2.3.1
To relink: brew unlink ruby && brew link ruby
➜  ~ git:(master) brew unlink ruby && brew link ruby
Unlinking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks removed
Linking /usr/local/Cellar/ruby/2.3.1... 1225 symlinks created
➜  ~ git:(master) ruby



輸入ruby後 卡住.....

重試

Last login: Wed Jul 13 14:02:14 on ttys002
➜  ~ git:(master) which ruby
/usr/local/bin/ruby
➜  ~ git:(master) brew install rbenv ruby-build
==> Installing dependencies for rbenv: autoconf, pkg-config, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.el_capitan.bottle.4.tar.g
######################################################################## 100.0%
==> Pouring autoconf-2.69.el_capitan.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
==> Installing rbenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1.el_capitan.bottle.tar
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.1: 10 files, 627.2K
==> Installing rbenv dependency: ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20160602.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20160602
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20160602: 282 files, 155.5K, built in 7 seconds
==> Installing rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.0.0.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring rbenv-1.0.0.el_capitan.bottle.tar.gz
==> Caveats
Rbenv stores data under ~/.rbenv by default. If you absolutely need to
store everything under Homebrew's prefix, include this in your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion, run this and follow the instructions:
  rbenv init
==> Summary
🍺  /usr/local/Cellar/rbenv/1.0.0: 36 files, 61.9K

➜  ~ git:(master)  

➜  ~ git:(master) brew install ruby
Warning: ruby-2.3.1 already installed
➜  ~ git:(master) ruby -v

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

可以看到ruby的版本

➜  ~ git:(master) rails -v
/usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'railties' (>= 0) among 11 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/QJpioneer/.gem/ruby/2.3.0:/usr/local/lib/ruby/gems/2.3.0:/usr/local/Cellar/ruby/2.3.1/lib/ruby/gems/2.3.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'

from /usr/local/bin/rails:22:in `<main>'

Rails 卻發生錯誤,嘗試重新安裝rails




➜  ~ git:(master) gem install nokogiri                               
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:

ERROR: Failed to build gem native extension.



After upgrading OS X from Mountain Lion to Maverick, encountered errors installing nokogiri. Resolved the error by reinstalling the command line tools.
  • brew doctor
  • xcode-select --install
執行以上兩個後,成功

➜  ~ git:(master) gem install nokogiri                                  
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.8

1 gem installed

➜  ~ git:(master) gem install rails                             
Fetching: loofah-2.0.3.gem (100%)

Successfully installed loofah-2.0.3
...
Successfully installed rails-5.0.0
26 gems installed
➜  ~ git:(master) rails -v
Rails 5.0.0







2016年3月19日 星期六

[Rails]錯誤解決-gem 'pg' 安裝PostgreSQL

主機環境:OSX EL Capitan 版本10.11.3

在學習 Ruby on Rails 遇到的錯誤:

An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.


這是在Gemfile 中加入 gem 'pg' 後,在Rails console (命令提示字元)輸入 #bundle install 後出現的錯誤。