Bundler not working with rbenv, could not find [gem]

前端 未结 10 1981
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 10:46

I\'ve just made the switch from rvm to rbenv and I\'m trying to use bundler for gem management. After running bundle install and trying to run

相关标签:
10条回答
  • 2020-12-04 11:20

    You should try using chruby. chruby is an ultra-minimal (~80 lines) alternative to RVM / rbenv. Unlike rbenv, chruby does not rely on shims and simply modifies PATH, GEM_HOME and GEM_PATH.

    0 讨论(0)
  • 2020-12-04 11:21

    Just a reminder too that rbenv is not compatible with rvm they do not play nicely. For your sanity, uninstall rvm if you want to use rbenv. From the rbenv README:

    Compatibility note: rbenv is incompatible with rvm. Things will appear to work until you try to install a gem. The problem is that rvm actually overrides the gem command with a shell function! Please remove any references to rvm before using rbenv.

    Luckily, Wayne (rvm creator) provides a remove rvm easily using:

    rvm implode

    As a regular use or:

    rvmsudo rvm implode

    To clean rvm system wide.

    0 讨论(0)
  • 2020-12-04 11:22

    Have you run

    rbenv rehash
    

    This will provide shims for all ruby binaries, including ones installed by gems.

    0 讨论(0)
  • 2020-12-04 11:22

    I suggest you use the gem 'capistrano-rbenv' (https://github.com/yyuu/capistrano-rbenv )

    1. make sure you have "rbenv" and a ruby version (e.g. 1.9.3) installed in remote server

    2. in your config/deploy.rb (capistrano file)

      require 'capistrano-rbenv'
      
    3. in your Gemfile:

      gem 'capistrano-rbenv', '1.0.1'
      
    4. that's it. to debug if it works, just run:

      $ cap shell
      cap> which ruby
       ** [out :: 10.103.13.74] /root/.rbenv/shims/ruby
      cap> ruby -v
       ** [out :: 10.103.13.74] ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
      
    0 讨论(0)
  • 2020-12-04 11:23

    I had a similar problem when I switched from using rvm to rbenv. I found my bundler was showing a different list of gems than my gem list command. First check to see which paths your bundler and gem are using. For bundler use the show command and select any gem.

    $ bundle show ffi
    /my/project/path/vendor/ruby/1.9.1/gems/ffi-1.1.5
    

    and my gem environment command (in part)

    $ gem environment
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.8.23
      - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin10.8.0]
      - INSTALLATION DIRECTORY: /Users/rolf/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
    

    Here I could see my gem is pointing to the correct rbenv path but my bundler is pointing to my project's vendor path.

    Running the following command should fix the bundler path problem:

    $ bundle install --system
    

    Bundler path should now be pointing to the rbenv path.

    $ bundle show ffi
    /Users/rolf/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/ffi-1.1.5
    

    Also I found when I run the rvm implode command to uninstall rvm, there were still the following files which I needed to change to remove rvm paths:

    ~/.profile
    ~/.bashrc
    ~/.zshrc
    

    If the ~/.rvm path still exists, you will need to remove this.

    You will need to open a new terminal session after changing these files. Finally after all that I finally got my bundler and gem in sync.

    0 讨论(0)
  • 2020-12-04 11:31

    Adding this

    set :default_environment, {
      'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
    }
    

    to deploy.rb worked for me.

    http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/

    0 讨论(0)
提交回复
热议问题