2013-06-19 118 views
1

(注:我發現了計算器同樣的問題,但它並沒有解決我的問題,所以我將提供有關的更多信息。)耙任務或捆綁的exec rake任務

我成立了一個RoR環境。它包含rvm,紅寶石,紅寶石在rails和bundler上。一切似乎都是正確的。

我切換到這個文件夾中包含一個RoR應用程序,並嘗試將數據庫

[email protected]:~/RubymineProjects/prototyp1$ rake db:reset 
rake aborted! 
cannot load such file -- bundler/setup 

(See full trace by running task with --trace) 
[email protected]:~/RubymineProjects/prototyp1$ 

錯誤:「無法加載這樣的文件 - 捆紮機/設置」 在另一邊「捆綁EXEC耙分貝:重置「按預期工作。

這裏我的環境值:

一紅寶石安裝:

[email protected]:~/RubymineProjects/prototyp1$ rvm list

rvm rubies

ruby-1.9.3-p194 [ x86_64 ] =* ruby-1.9.3-p429 [ x86_64 ]
ruby-2.0.0-p195 [ x86_64 ]

因此, 「紅寶石1.9.3-429頁」 是我目前和默認紅寶石版本。

二,使用gemset

[email protected]:~/RubymineProjects/prototyp1$ rvm gemset list

gemsets for ruby-1.9.3-p429 (found in /home/katarina/.rvm/gems/ruby-1.9.3-p429)
(default)
global

=> prototyp1

所以我使用在當前的ruby版本內創建的prototyp1 gemset。

三,包含寶石:

注意:$ GEM_HOME指向正確的gemset和gem列表返回包含捆綁器的項目。

[email protected]:~/RubymineProjects/prototyp1$ cd $GEM_HOME 
[email protected]:~/.rvm/gems/[email protected]$ gem list 

*** LOCAL GEMS *** 

actionmailer (3.2.8) 
actionpack (3.2.8) 
activemodel (3.2.8) 
activerecord (3.2.8) 
activeresource (3.2.8) 
activesupport (3.2.8) 
addressable (2.3.4, 2.3.3) 
arel (3.0.2) 
bcrypt-ruby (3.0.1) 
better_errors (0.9.0) 
binding_of_caller (0.7.2) 
bootstrap-sass (2.3.2.0) 
builder (3.0.4, 3.0.3) 
bundler (1.2.0) 
cancan (1.6.10) 
capybara (2.1.0) 
chunky_png (1.2.6) 
coderay (1.0.9) 
coffee-rails (3.2.2) 
coffee-script (2.2.0) 
coffee-script-source (1.6.2, 1.4.0, 1.3.3) 
compass (0.12.2) 
cucumber (1.3.2) 
cucumber-rails (1.3.1) 
daemons (1.1.9) 
database_cleaner (1.0.1) 
debug_inspector (0.0.2) 
devise (2.2.4) 
diff-lcs (1.2.4, 1.1.3) 
email_spec (1.4.0) 
erubis (2.7.0) 
eventmachine (1.0.3) 
excon (0.16.10) 
execjs (1.4.0) 
factory_girl (4.2.0) 
factory_girl_rails (4.2.1) 
faraday (0.8.7) 
figaro (0.6.4) 
fssm (0.2.9) 
gherkin (2.12.0) 
hashie (2.0.5) 
heroku (2.35.0) 
heroku-api (0.3.8) 
hike (1.2.3, 1.2.1) 
httpauth (0.2.0) 
hub (1.10.6) 
i18n (0.6.4) 
journey (1.0.4) 
jquery-rails (3.0.1, 2.1.4, 2.1.2) 
json (1.8.0, 1.7.5) 
jwt (0.1.8) 
launchy (2.3.0, 2.2.0) 
libv8 (3.11.8.17 x86_64-linux, 3.3.10.4 x86_64-linux) 
mail (2.4.4) 
mime-types (1.23, 1.19) 
mini_portile (0.5.0) 
multi_json (1.7.7, 1.4.0, 1.3.6) 
multipart-post (1.2.0) 
netrc (0.7.7) 
nokogiri (1.6.0, 1.5.5) 
oauth (0.4.7) 
oauth2 (0.8.1) 
omniauth (1.1.4) 
omniauth-facebook (1.4.1) 
omniauth-linkedin (0.1.0) 
omniauth-oauth (1.0.1) 
omniauth-oauth2 (1.1.1) 
omniauth-twitter (0.0.17) 
orm_adapter (0.4.0) 
pg (0.14.1) 
polyglot (0.3.3) 
quiet_assets (1.0.2) 
rack (1.5.2, 1.4.5) 
rack-cache (1.2) 
rack-ssl (1.3.3, 1.3.2) 
rack-test (0.6.2, 0.6.1) 
rails (3.2.8) 
railties (3.2.8) 
rake (10.0.4, 10.0.2, 0.9.2.2) 
rdoc (3.12.2, 3.12) 
ref (1.0.5) 
rest-client (1.6.7) 
rolify (3.2.0) 
rspec (2.11.0, 2.0.1) 
rspec-core (2.13.1, 2.11.1, 2.0.1) 
rspec-expectations (2.13.0, 2.11.3, 2.0.1) 
rspec-mocks (2.13.1, 2.11.3, 2.11.2, 2.0.1) 
rspec-rails (2.13.2, 2.11.0, 2.0.1) 
rubygems-bundler (1.1.0) 
rubyzip (0.9.9) 
rvm (1.11.3.5) 
sass (3.2.9, 3.2.3, 3.2.1) 
sass-rails (3.2.6, 3.2.5) 
simple_form (2.1.0) 
sprockets (2.1.3) 
sqlite3 (1.3.7, 1.3.6) 
therubyracer (0.11.4, 0.10.2) 
thin (1.5.1, 1.5.0) 
thor (0.18.1, 0.16.0) 
tilt (1.4.1, 1.3.3) 
treetop (1.4.14, 1.4.12, 1.4.10) 
tzinfo (0.3.37, 0.3.35, 0.3.33) 
uglifier (2.1.1, 1.3.0) 
warden (1.2.1) 
webrat (0.7.1) 
webrick (1.3.1) 
xpath (2.0.0) 

爲什麼在執行rake時會出現錯誤? 這是執行耙式任務的「老式」方式嗎?建議執行「bundle exec ..」而不是「rake ...」?

預先感謝您。 golbie

回答

3

強烈建議使用bundle exec執行任務。它確保任務在當前包的上下文中執行。

+0

您可以使用[bundler-exec](https://github.com/gma/bundler-exec)或[oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) )的捆綁器插件可以自動預先加入'bundle exec'。 – Stefan