Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find bundler #369

Closed
guxiaobai opened this issue May 19, 2016 · 11 comments
Closed

Could not find bundler #369

guxiaobai opened this issue May 19, 2016 · 11 comments

Comments

@guxiaobai
Copy link

Software

  • osx 10.11.4
  • rbenv 1.0.0
  • ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
  • Rails 4.2.6

bundle exec gem list|grep guard

guard (2.13.0)
guard-compat (1.2.1)
guard-rspec (4.6.5)

bundle exec guard -d

RubyDep: WARNING: Your Ruby has security vulnerabilities! (To disable warnings, set RUBY_DEP_GEM_SILENCE_WARNINGS=1)
RubyDep: WARNING: Your Ruby is: 2.2.3 (insecure). Recommendation: install 2.2.5 or 2.3.1. (Or, at least to 2.2.4 or 2.3.0)
00:54:56 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
00:54:56 - DEBUG - Notiffany: growl not available (Please add "gem 'growl'" to your Gemfile and run your app with "bundle exec".).
00:54:56 - DEBUG - Notiffany: terminal_notifier not available (Please add "gem 'terminal-notifier-guard'" to your Gemfile and run your app with "bundle exec".).
00:54:56 - DEBUG - Notiffany: libnotify not available (Unsupported platform "darwin15.4.0").
00:54:56 - DEBUG - Notiffany: notifysend not available (Unsupported platform "darwin15.4.0").
00:54:56 - DEBUG - Notiffany: notifu not available (Unsupported platform "darwin15.4.0").
00:54:56 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
00:54:56 - DEBUG - Notiffany: emacs not available (Emacs client failed).
00:54:56 - DEBUG - Notiffany: tmux not available (:tmux notifier is only available inside a TMux session.).
00:54:56 - DEBUG - Notiffany: file not available (No :path option given).
00:54:56 - DEBUG - Notiffany is using TerminalTitle to send notifications.
00:54:56 - DEBUG - Command execution: hash stty
00:54:56 - DEBUG - Guard starts all plugins
00:54:56 - DEBUG - Hook :start_begin executed for Guard::RSpec
00:54:56 - INFO - Guard::RSpec is running
00:54:56 - DEBUG - Hook :start_end executed for Guard::RSpec
00:54:56 - INFO - Guard is now watching at '/Users/lemon/Documents/chavis'
00:54:56 - DEBUG - Start interactor
00:54:56 - DEBUG - Command execution: stty -g 2>/dev/null
[1] guard(main)>
00:54:58 - DEBUG - Interactor was stopped or killed
00:54:58 - DEBUG - Command execution: stty  2>/dev/null
00:54:58 - INFO - Run all
00:54:58 - DEBUG - Hook :run_all_begin executed for Guard::RSpec
00:54:58 - INFO - Running all specs
/Users/lemon/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 98 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0', execute `gem env` for more information
    from /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
    from /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from /Users/lemon/.rbenv/versions/2.2.3/bin/bundle:22:in `<main>'
00:54:58 - ERROR - Failed: "bundle exec rspec -f progress -r /Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.5/lib/guard/rspec_formatter.rb -f Guard::RSpecFormatter --failure-exit-code 2  spec" (exit code: 1)

00:54:58 - DEBUG - Start interactor
00:54:58 - DEBUG - Command execution: stty -g 2>/dev/null

gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.5.1
  - RUBY VERSION: 2.2.3 (2015-08-18 patchlevel 173) [x86_64-darwin15]
  - INSTALLATION DIRECTORY: /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0
  - RUBY EXECUTABLE: /Users/lemon/.rbenv/versions/2.2.3/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/lemon/.rbenv/versions/2.2.3/bin
  - SPEC CACHE DIRECTORY: /Users/lemon/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/lemon/.rbenv/versions/2.2.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0
     - /Users/lemon/.gem/ruby/2.2.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://gems.ruby-china.org/"]
  - REMOTE SOURCES:
     - https://gems.ruby-china.org/
  - SHELL PATH:
     - /Users/lemon/.rbenv/versions/2.2.3/bin
     - /usr/local/Cellar/rbenv/1.0.0/libexec
     - /Users/lemon/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
@e2
Copy link
Contributor

e2 commented May 19, 2016

What happens if you run this?

bundle exec rspec -f progress -r /Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.5/lib/guard/rspec_formatter.rb -f Guard::RSpecFormatter --failure-exit-code 2  spec

@e2
Copy link
Contributor

e2 commented May 19, 2016

Also, this seems related: guard/guard-bundler#32

So you are probably using bundle install --path.

Notice that your GEM_PATH on your system is:

GEM PATHS:
     - /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0
     - /Users/lemon/.gem/ruby/2.2.0

while your GEM_PATH inside your project is: GEM_PATH=/Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0

(And that's why you get the error: bundler isn't installed in that last location).

Try this workaround here: guard/guard-bundler#32 (comment)

@guxiaobai
Copy link
Author

ths @e2

now i don't use --path on bundle > 1.12.x

command

# with --path vendor/bundle
bundle exec rspec -f progress -r /Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.5/lib/guard/rspec_formatter.rb -f Guard::RSpecFormatter --failure-exit-code 2  spec

# output

0 examples, 0 failures
Guard::RSpec: Warning: no environment passed - see https://github.com/guard/guard-rspec/wiki/Warning:-no-environment
Guard::RSpec: Warning: :results_file value unknown (using defaults)

test

#Guardfile
Kernel.system("gem env")

# without --path
GEM PATHS:
     - /Users/lemon/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0
     - /Users/lemon/.gem/ruby/2.2.0

# with --path vendor/bundle
GEM PATHS:
    - /Users/lemon/Documents/chavis/vendor/bundle/ruby/2.2.0

@e2
Copy link
Contributor

e2 commented May 20, 2016

I'm wondering what the solution should be. And where it should be implemented.

If it's just Guard::RSpec you need, you can probably just change

guard :rspec, cmd: 'bundle exec rspec'

to

guard :rspec, cmd: 'rspec'

Because, if you run Guard with bundle exec guard, then you don't need to run RSpec with bundler.

The other option is to use the short popen3 trick mentioned in the other thread (to install bundler in the vendor/bundle path if it doesn't exist).

Hope that helps.

@andoq
Copy link

andoq commented May 24, 2016

I ran into this as well, and after some investigation I saw that in rspec_process line 70, a bundler method with_clean_env is being used. Looking at that in bundler, I saw a notice about clean_env being deprecated in favor of original_env. And changing the line solved this problem for me. So line 70 in rspec_process.rb becomes:

::Bundler.with_original_env { yield }

Unsure if there are any wider implications, or if bundler should fix the original method. But this worked as a workaround for me.

@e2
Copy link
Contributor

e2 commented May 25, 2016

Yes, I suspected something like this.

I didn't know about original_env - but it seems like it actually does
what the original code is likely supposed to do anyway.

To be on the safe side, I'd suggest a Guard::RSpec configuration
option that would have 3 values:

  1. :clean_env (current behavior)
  2. :original_env (fixed behavior)
  3. :inherit (no wrapper block)

This is because since you can pass any command to Guard::RSpec to run
the tests, it also makes sense for the user to decide what kind of
environment they want.

E.g. some users may prefer to run RSpec without bundler at all (for
faster start up?), even though the main process may be using Bundler.

If someone can create a PR for this, I'd be happy to merge it.

On Tue, May 24, 2016 at 03:11:19PM -0700, Andy Camp wrote:

I ran into this as well, and after some investigation I saw that in rspec_process line 70, a bundler method with_clean_env is being used. Looking at that in bundler, I saws a notice about clean_env being deprecated in favor of original_env. And changing the line solved this problem for me. So line 70 in rspec_process.rb becomes:

::Bundler.with_original_env { yield }

Unsure if there are any wider implications, or if bundler should fix the original method. But this worked as a workaround for me.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#369 (comment)

@e2
Copy link
Contributor

e2 commented Jun 2, 2016

Fix released in 4.2.7. (Thanks to @soberstadt !)

@e2 e2 closed this as completed Jun 2, 2016
@benlangfeld
Copy link

Is 4.2.7 really correct @e2? The latest version of this gem is 4.7.1, and 4.2.7 was released in February. Maybe you meant to release as 4.7.2, but this failed?

@soberstadt
Copy link
Contributor

Yes, I think there might have been a mix up. You made the tag: https://github.com/guard/guard-rspec/releases/tag/v4.7.2 but it hasn't made it to rubygems yet.

@e2
Copy link
Contributor

e2 commented Jun 2, 2016

@benlangfeld , @soberstadt - yes, gem push seemed to have failed :( Credential issues likely.

Fixed.

@benlangfeld
Copy link

Thanks @e2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants