2012-10-10 1 views
3

cakephp 환경에서 db migration을 수행하기 위해 https://github.com/thuss/standalone-migrations을 사용하고 있습니다. 나는 궁극적으로 post-checkout git hook을 사용하여 다른 버전의 코드를 체크 아웃 한 후에 자동으로 db 마이그레이션을 수행하려고 시도하고있다.rake db : migrate in git hook - 정의되지 않은 클래스/모듈 인코딩

정상적으로 cli bundle exec rake db:migrate에서 실행중인 경우, rake db:migrate 또는 다른 명령과 마찬가지로 정상적으로 작동합니다. .git/hooks/post-checkout에 명령을 입력하면 오류 메시지가 표시됩니다. undefined class/module Encoding

git hook 명령은 bundle exec rake db:migrate --trace입니다.

플랫폼 :

 
rake aborted! 
undefined class/module Encoding 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib/json/ext/parser.bundle 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib/json/ext.rb:13 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib/json.rb:58:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/lib/json.rb:58 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/object/to_json.rb:3:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/object/to_json.rb:3 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/object.rb:10:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext/object.rb:10 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext.rb:2:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext.rb:2 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext.rb:1:in `each' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/core_ext.rb:1 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/all.rb:3:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/all.rb:3 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/standalone_migrations/configurator.rb:1:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/standalone_migrations/configurator.rb:1 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/standalone_migrations.rb:8:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/standalone_migrations.rb:8 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/tasks/standalone_migrations.rb:9:in `require' 
/Users/andy/.rvm/gems/ruby-1.9.3-p194/gems/standalone_migrations-2.0.1/lib/tasks/standalone_migrations.rb:9 
/Users/andy/source/idio/cake/Rakefile:6:in `require' 
/Users/andy/source/idio/cake/Rakefile:6 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/andy/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/usr/bin/rake:31 

내가 루비 너무 뜨거운 아니에요 : 맥 OS X 라이온 10.7.5

이 전체 오류입니다. 나는 모든 종류의 트릭을 시도하고, 모든 보석을 삭제하고, 재설치했다. 항상 똑같다.

감사합니다.

답변

1

이것은 git이 후크 내에서 $ PATH에/usr/bin을 다시 추가 할 때 발생하는 문제입니다. 이로 인해 내 rvm 버전 대신 루비의 OS 버전 (/ usr/bin에 있음)이 호출됩니다. OS 버전은 1.8.7이며 올바른 보석 등은 없습니다. 1.9.3을 사용하고 있습니다.

후크 내에서 rvm 설정 스크립트의 소스를 찾아야합니다. 다음과 같음 :

#!/usr/bin/env bash 
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

# ...rest of the post commit commands