bundle install not installing all dependencies

2019-04-12 12:19发布

问题:

I am on Mac OS X, and when I run sudo bundle install, it installs several gems on the target machine:

Installing ptools (1.2.1) 
Using thor (0.14.6) 
Using railties (3.0.5) 
Using rails (3.0.5) 
Installing rails_config (0.2.4) 
Using shoulda (2.11.3) 
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
imac-cf:gnymbus apple$ rails console
Could not find rake-0.9.2 in any of the sources
imac-cf:gnymbus apple$ sudo gem install rake-0.9.2
ERROR:  Could not find a valid gem 'rake-0.9.2' (>= 0) in any repository
imac-cf:gnymbus apple$ sudo gem install rake -v=0.9.2
Successfully installed rake-0.9.2
1 gem installed
Installing ri documentation for rake-0.9.2...
Installing RDoc documentation for rake-0.9.2...
imac-cf:gnymbus apple$ sudo gem install rake-0.9.2
^CERROR:  Interrupted
imac-cf:gnymbus apple$ rails console
Could not find i18n-0.6.0 in any of the sources
imac-cf:gnymbus apple$ sduo gem install i18n -v=0.6.0
-bash: sduo: command not found
imac-cf:gnymbus apple$ sudo gem install i18n -v=0.6.0
Successfully installed i18n-0.6.0
1 gem installed
Installing ri documentation for i18n-0.6.0...
Installing RDoc documentation for i18n-0.6.0...

So, it should be safe to assume that dependencies are resolved for the app, and things are ready to go. But they are not.

When I run rails console, I constantly receive output about more and more and more and more unresolved dependencies:

imac-cf:gnymbus apple$ rails console
Could not find tzinfo-0.3.29 in any of the sources
imac-cf:gnymbus apple$ sudo gem install tzingo -v=0.3.29
ERROR:  Could not find a valid gem 'tzingo' (= 0.3.29) in any repository
imac-cf:gnymbus apple$ sudo gem install tzinfo -v=0.3.29
Successfully installed tzinfo-0.3.29
1 gem installed
Installing ri documentation for tzinfo-0.3.29...
Installing RDoc documentation for tzinfo-0.3.29...
imac-cf:gnymbus apple$ rails console
Could not find polyglot-0.3.2 in any of the sources
imac-cf:gnymbus apple$ sudo gem install polyglot -v=0.3.2
Successfully installed polyglot-0.3.2
1 gem installed
Installing ri documentation for polyglot-0.3.2...
Installing RDoc documentation for polyglot-0.3.2...
imac-cf:gnymbus apple$ rails console
Could not find treetop-1.4.10 in any of the sources
imac-cf:gnymbus apple$ sudo gem install treetop -v=1.4.10
Successfully installed treetop-1.4.10
1 gem installed
Installing ri documentation for treetop-1.4.10...
Installing RDoc documentation for treetop-1.4.10...
imac-cf:gnymbus apple$ rails console
Could not find mail-2.2.19 in any of the sources
imac-cf:gnymbus apple$ sudo gem install mail -v=2.2.19
Successfully installed mail-2.2.19
1 gem installed
Installing ri documentation for mail-2.2.19...
Installing RDoc documentation for mail-2.2.19...
imac-cf:gnymbus apple$ rails console
Could not find addressable-2.2.6 in any of the sources

Is Rails really this difficult? Do I really have to install dependencies manually, one by one? What am I doing wrong?

回答1:

  1. Delete Gemfile.lock
  2. Delete all gems under root (it's prefer)
  3. Update rubygems
  4. gem install bundler
  5. bundle install


回答2:

I used

bundle update 

it updated all the Gemfiles and installed the missing gems. No sudo, since using RVM



回答3:

On Mac OSX, I had the same problem. All I needed to do was:

gem install bundler


回答4:

If you are using Vagrant, try restarting your VM. Often when going back and forth between work and home I've noticed that the VM's connection to the outside world gets hosed. In this case running rails console will check for any unmet dependencies and fail simply because it can't connect to ruby gems.org.

It's a really bad error message and has caught me off-guard on more than one occasion.



回答5:

Okay, the problem was that I had to not run bundle install using sudo.

What a pain. Why are these sorts of things not documented somewhere?