Ruby-on-rails 捆绑:在 mac 上找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8276173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:24:33  来源:igfitidea点击:

bundle: command not found on mac

ruby-on-rails

提问by john john

I am trying to create a brand new Rails application and it is asking me to run 'bundle install'. However, whenever I do this I get a command not found error.

我正在尝试创建一个全新的 Rails 应用程序,它要求我运行“捆绑安装”。但是,每当我这样做时,我都会收到一个未找到命令的错误。

My path has both ruby and the gem folder on it. Is bundle a executable file? Where is it commonly stored?

我的路径上有 ruby​​ 和 gem 文件夹。捆绑是可执行文件吗?一般存放在哪里?

I think it could be a path issue, with multiple Ruby versions installed.

我认为这可能是路径问题,安装了多个 Ruby 版本。

Path: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

路径:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

gem env:

宝石环境:

RubyGems Environment:
RUBYGEMS VERSION: 1.8.10
RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]
INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
EXECUTABLE DIRECTORY: /usr/bin
RUBYGEMS PLATFORMS:
- ruby
 - universal-darwin-10
GEM PATHS:
 - /Library/Ruby/Gems/1.8
 - /Users/john/.gem/ruby/1.8
 - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
 REMOTE SOURCES:
 - http://rubygems.org/

which ruby returns /usr/bin/ruby

哪个 ruby​​ 返回 /usr/bin/ruby

I think the ruby executable gem is trying to run is not pointing to the right place..

我认为 ruby​​ 可执行 gem 试图运行没有指向正确的地方..

回答by ptim

I had a similar issue, and the following worked for me:

我有一个类似的问题,以下对我有用:

  • install bundler: gem install bundler
  • add the gems executable to my path
  • 安装捆绑器: gem install bundler
  • 将 gems 可执行文件添加到我的路径

To add gem to the path, compare the following:

要将 gem 添加到路径,请比较以下内容:

  • echo $PATH
  • which gem
  • echo $PATH
  • which gem

if the gem executable is not in your path, then add it to your ~/.bash_profile by editing the line: export PATH="$PATH:/usr/local/var/rbenv/shims/gem"

如果 gem 可执行文件不在您的路径中,则通过编辑以下行将其添加到您的 ~/.bash_profile 中: export PATH="$PATH:/usr/local/var/rbenv/shims/gem"

In my example above, the existing path is referenced by $PATH, and I've pasted the location returned by which gem, separated by a colon :

在上面的示例中,现有路径由 $PATH 引用,并且我粘贴了由 返回的位置which gem,以冒号分隔:

I'm on a OSX 10.8.3 and gem was installed via homebrew. my path has a bunch of additions, so it looks like:

我在 OSX 10.8.3 上,gem 是通过自制软件安装的。我的路径有一堆附加内容,所以它看起来像:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:~/bin:/usr/local/var/rbenv/shims/gem:$PATH"

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:~/bin:/usr/local/var/rbenv/shims/gem:$PATH"

Each path is separated by a colon, and the $PATH variable sits at the end. not sure if it matters :)

每个路径用冒号分隔,$PATH 变量位于末尾。不确定是否重要:)