簡體   English   中英

使用 capistrano 3.16.0 然后 cap: command not found

[英]Using capistrano 3.16.0 then cap: command not found

我可以從我的 Gemfile gem 'capistrano', '~> 3.16.0'安裝 capistrano。 已安裝 Capistrano

但是bash找不到cap命令。 找不到 cap 命令

不確定如何解決這個問題,我在我的 MacBook Air M1 上運行 bash。

為什么前置bundle exec有效?

  • 在包的上下文中執行命令。
  • 此命令執行命令,使 Gemfile 中指定的所有 gem 可用於 Ruby 程序中。
  • 這確保可執行腳本使用該項目的 Gemfile 中的 gem 版本,而不是機器上系統范圍內安裝的其他版本

本質上,如果您通常會運行類似rspec spec/my_spec.rb的程序,並且您想要使用 Gemfile 中指定並通過 bundle install 安裝的 gem,您應該運行bundle exec rspec spec/my_spec.rb.

來源

如果我不想使用bundle exec怎么辦?

1.使用Bundler的binstubs

對於 rbenv https://github.com/rbenv/rbenv/wiki/Understanding-binstubs#project-specific-binstubs

對於 RVM https://rvm.io/integration/bundler

2. 在計算機的.bash_profile 或.zshrc 中為bundle exec設置一個別名用於zsh。

理想情況下,我們會將 alias be='bundle exec'添加到.bash_profile.zshrc並運行我們的可執行文件,並將be添加到命令中。 示例: be rake

暫無
暫無

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

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