簡體   English   中英

rake task或bundle exec rake任務

[英]rake task OR bundle exec rake task

(注意:我在stackoverflow上發現了同樣的問題,但它沒有解決我的問題所以我將提供更多的信息。)

我建立了一個RoR環境。 它包含rvm,ruby,ruby on rails和bundler。 一切似乎都是正確的。

我切換到包含RoR應用程序的文件夾,並嘗試重置數據庫

katarina@katarina-VirtualBox:~/RubymineProjects/prototyp1$ rake db:reset
rake aborted!
cannot load such file -- bundler/setup

(See full trace by running task with --trace)
katarina@katarina-VirtualBox:~/RubymineProjects/prototyp1$ 

錯誤:“無法加載此類文件 - bundler / setup”另一方面“bundle exec rake db:reset”按預期工作。

這里我的環境值:

I.紅寶石安裝:

katarina @ katarina-VirtualBox:〜/ RubymineProjects / prototyp1 $ rvm list

rvm紅寶石

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

所以“ruby-1.9.3-p429”是我當前和默認的ruby版本。

II。 用過的寶石

katarina @ katarina-VirtualBox:〜/ RubymineProjects / prototyp1 $ rvm gemset list

gemy for ruby​​-1.9.3-p429(見/home/katarina/.rvm/gems/ruby-1.9.3-p429)
(默認)
全球

=> prototyp1

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

III。 包含寶石:

注意:$ GEM_HOME指向正確的gemset,gem列表返回包含bundler的項目。

katarina@katarina-VirtualBox:~/RubymineProjects/prototyp1$ cd $GEM_HOME
katarina@katarina-VirtualBox:~/.rvm/gems/ruby-1.9.3-p429@prototyp1$ 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時遇到錯誤? 這是執行rake任務的“老式”方式嗎? 建議執行“bundle exec ..”而不是“rake ...”?

先感謝您。 golbie

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM