Michał Sadowski
Michał Sadowski

Reputation: 2155

Bundler doesn't get installed properly

I'm just so lost. I set up Ubuntu on Windows and installed rbenv using curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash. Added relevant lines to my .zshrc file, installed necessary ruby version, so now ruby -v command shows ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux] as it should. I ran sudo gem install bundler which printed nicely Successfully installed bundler-2.0.1. But when I run bundler command I get:

Traceback (most recent call last):
        2: from /home/michal-sadowski/.rbenv/versions/2.5.3/bin/bundler:23:in `<main>'
        1: from /home/michal-sadowski/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/home/michal-sadowski/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException)

What can I do to get it run?

which bundler gives /home/michal-sadowski/.rbenv/shims/bundler which ruby gives /home/michal-sadowski/.rbenv/shims/ruby

Upvotes: 0

Views: 384

Answers (1)

Michał Sadowski
Michał Sadowski

Reputation: 2155

It was a mix of issues.

  1. I shouldn't have used sudo, very plausible that it broke some paths
  2. I shouldn't have to use sudo in the first place - but installing ruby directly through sudo apt install ruby-full most likely set restrictive access to necessary folders
  3. After uninstalling system default ruby version and reinstalling rbenv I could call bundler without an error - just not in the right folder. Turned out that the issue was a gemlock file that had a bundled with field set to 1.x, caused by one old gemfile. After removing the gemlock file and that dependency - it went more or less smoothly.

Upvotes: 1

Related Questions