简体   繁体   中英

Bundler installing Git dependencies to wrong directory

I'm having an issue installing Git dependencies with Bundler. bundle install appears to finish successfully:

Using gemname version from git://github.com/username/repo.git (at master)
Your bundle is complete!

However, running any subsequent commands, bundle exec etc. it fails:

git://github.com/username/repo.git (at master) is not yet checked out. Run `bundle install` first.

I have noticed that Bundler has no problem fetching the gem but it is being installed into the local /home/rails/.bundler/ruby/2.1.0/ directory (and why "Ruby 2.1.0" I don't know...) rather than to where it should be at /usr/local/rvm/gems/ruby-2.1.3/ alongside all the other gems.

I've tried clearing out the local Bundler caches and configs and running bundle install again in case there was a simple problem there but that hasn't helped.

Gem env:

- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.3 (2014-09-19 patchlevel 242) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.1.3
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.1.3/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.1.3/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- RUBYGEMS PLATFORMS:
  - ruby
  - x86_64-linux
- GEM PATHS:
   - /usr/local/rvm/gems/ruby-2.1.3
   - /usr/local/rvm/gems/ruby-2.1.3@global
- GEM CONFIGURATION:
   - :update_sources => true
   - :verbose => true
   - :backtrace => false
   - :bulk_threshold => 1000
- REMOTE SOURCES:
   - https://rubygems.org/

Do not run sudo bundle install — this causes git gems to be installed into the wrong location.

When running as a user that can't write to the normal gem installation location ( GEM_HOME ), Bundler expects to find git gems in $HOME/.bundler . Installing with sudo bypasses this behaviour (because you can write to any location as root), and requires you to also bundle exec as root.

Instead run bundle install without sudo, as the same user that that will be running bundle exec .

If root permissions are required to install other gems, Bundler internally invokes sudo. See http://bundler.io/man/bundle-install.1.html#SUDO-USAGE for details.

Using the --deployment flag avoids this issue because in deployment mode all gems (git-sourced and otherwise) are installed into the vendor/bundle directory within your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM