tpope / vim-bundler

bundler.vim: Lightweight support for Ruby's Bundler
https://www.vim.org/scripts/script.php?script_id=4280
404 stars 29 forks source link

Unable to open gems managed by rbenv #43

Open tylernm14 opened 8 years ago

tylernm14 commented 8 years ago

I'm using vim 7.4, vim-rbenv, and the latest vim-bundler code, and I'm having trouble with :Bopen . :Bundle works for me as expected but :Bopen is returning the error "Gem is in bundle but not installed". Also in my Gemfile.lock all ruby gems are highlighted as not being installed. Heres the output of two commands run from within vim:

 !ruby -rubygems -e "print Gem.path.join(';')"
/Users/tylernm/.gem/ruby/2.3.0;/Users/tylernm/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
:!ruby -rrbconfig -e "print RbConfig::CONFIG[\"ruby_version\"]"
2.3.0

which is the exact same output as on my command line shell (zsh). All this seems to point to a gem_path issue. Do you have any tips on how to debug this further? Unfortunately I'm very new to vimscript. Thanks.

tpope commented 8 years ago

That first one looks strange; can you confirm it's as expected?

tylernm14 commented 8 years ago

Happily. I'm not exactly sure what it's supposed to look like; however, the first directory /Users/tylernm/.gem/ruby/2.3.0 doesn't actually exist. I have a /Users/tylernm/.gem/ directory with a credentials file and a "spec" folder, but no "ruby" folder. The second directory is actually present and has my ruby 2.3.1 gems.

Heres the output of gem environment on the command line:

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

As mentioned, the user installation directory doesnt actually exist on my system. Not sure if that's actually an issue. Did some reading and discovered that that directory is for gems install with --user-install.
Running the same command inside vim yeilds:

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

It seems that actually a bash function in my zshrc that I use to launch vim is causing this issue. Running the vim binary from the command line without using my bash function remedies my problems with vim-bundler. I guess that this function is messing with the working directory for the binary.

tylernm14 commented 8 years ago

Hey there. I'm reopening this issue as I've uncovered some weirdness happening with macvim. It seems that when I launch macvim from a terminal vim-bundler initializes correctly and I can :Bopen <gem name> just fine. However when I launch macvim from osx finder and I use ther graphical window (preferred usage because of faster mouse movement), the gem open command above fails. I've compared the paths between the two version of macvim and they seem correct. The graphical macvim :Bopen command reports Gem <name> is in bundle but not installed. I've checked verbose set path? and they look identical in both versions of macvim. Are there any other variables that I can check to sort this out? Any chance that the graphical macvim. Below is the output from my graphical macvim:

:verbose set path?

path=~/src/svcscenes/lib,~/src/svcscenes/vendor,~/src/svcscenes/app/models/concerns,~/src/svcscenes/app/controllers/concerns,~/src/svcscenes/app/controllers,~/src/svcscenes
/app/helpers,~/src/svcscenes/app/mailers,~/src/svcscenes/app/models,~/src/svcscenes/app/*,~/src/svcscenes/app/views,~/src/svcscenes/spec,~/src/svcscenes/spec/controllers,~/sr
c/svcscenes/spec/helpers,~/src/svcscenes/spec/mailers,~/src/svcscenes/spec/models,~/src/svcscenes/spec/views,~/src/svcscenes/spec/lib,~/src/svcscenes/spec/features,~/src/svcs
cenes/spec/requests,~/src/svcscenes/spec/integration,~/src/svcscenes/vendor/plugins/*/lib,~/src/svcscenes/vendor/plugins/*/test,~/src/svcscenes/vendor/rails/*/lib,~/src/svcsc
enes/vendor/rails/*/test,~/src/svcscenes,~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0,~/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/x86_64-darwin15,~/.rbenv/versions/2
.3.1/lib/ruby/site_ruby,~/.rbenv/versions/2.3.1/lib/ruby/vendor_ruby/2.3.0,~/.rbenv/versions/2.3.1/lib/ruby/vendor_ruby/2.3.0/x86_64-darwin15,~/.rbenv/versions/
        Last set from ~/mysrc/env-config/vim/bundle/vim-bundler/plugin/bundler.vim

I'm totally stumped. I guess my next step is to start throwing in "echo"s into vim-bundler and debug the script.

tpope commented 7 years ago

That path is a bit too short to actually see any gems. Check :echo &path (or more readable, :echo pathogen#split(&path)) instead.