gem 安装捆绑器后捆绑安装仍然无法正常工作

Bundle install still not working after gem install bundler

我最初尝试使用 bundle install 但出现错误 'command not found.' 我试过了

gem install bundler

然后尝试捆绑安装,但仍然出现相同的错误,'bundle: command not found.'

供参考:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.1
  - RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
  - INSTALLATION DIRECTORY: /usr/local/opt/gems
  - USER INSTALLATION DIRECTORY: /Users/willashley23/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/local/opt/rbenv/versions/2.3.1/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/opt/gems/bin
  - SPEC CACHE DIRECTORY: /Users/willashley23/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/opt/rbenv/versions/2.3.1/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /usr/local/opt/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/opt/rbenv/versions/2.3.1/bin
     - /usr/local/Cellar/rbenv/1.0.0/libexec
     - /usr/local/opt/rbenv/shims
     - /Users/willashley23/.rbenv/bin
     - /usr/local/bin
     - /usr/local/sbin
     - ~/bin
     - /Users/willashley23/.rbenv/bin
     - /Users/willashley23/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin 

编辑 添加 Gemfile:

 source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

好吧,根据你的尝试,我想出了一些东西。

1.Install 全局 gemset 的捆绑器。 rvm gemset use global && gem install bundler

2.In 如果你安装了 Homebrew:尝试 brew install ruby

3.If 以上解决方案不起作用可能是因为您没有正确获取 rvm,因为您没有登录 shell,因此 运行

source ~/.rvm/scripts/rvm

然后就可以执行bundle install.

4.Last 事情是因为你已经在使用 rvm ,可能是因为 rvm 没有被选为默认值所以 运行

rvm use 2.1.1 --default

然后是运行bundle install

5.Also 你可以在安装 bundler 之前尝试 rvm get head && rvm reload

如果我遗漏了什么,请告诉我。