繁体   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