Bunder is installing with rubygems dependency not version in gem directory - ruby-on-rails

I'm using rbenv to manage my Rubies. Heroku seems to only (or at least prefer) Bundler v1.15.2 according to their Ruby Support docs.
So I:
$ bundle exec gem install bundler -v 1.15.2
and that's the only version of Bundler in Ruby 2.4.4's gem directory.
However when I bundle install or bundle update the Gemfile.lock says:
BUNDLED WITH
1.16.2
And that gives me warnings in deployment (Heroku) and even locally every time I bundle update <some_gem>.
I did update rubygems recently:
$ gem -v
2.6.14.1
$ gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.7.7.gem (100%)
Successfully installed rubygems-update-2.7.7
Installing RubyGems 2.7.7
Bundler 1.16.2 installed
RubyGems 2.7.7 installed
Regenerating binstubs
Which explains why bundler 1.16.2 is on my system but how can I force it to source the version in Ruby's directory and put an end to all these warnings:
Warning: the running version of Bundler (1.15.2) is older than the
version that created the lockfile (1.16.2). We suggest you upgrade to
the latest version of Bundler by running gem install bundler.
Edit: gem env as per request
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.7
- RUBY VERSION: 2.4.4 (2018-03-28 patchlevel 296) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/meltemi/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/meltemi/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/meltemi/.rbenv/versions/2.4.4/bin/ruby
- EXECUTABLE DIRECTORY: /Users/meltemi/.rbenv/versions/2.4.4/bin
- SPEC CACHE DIRECTORY: /Users/meltemi/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/meltemi/.rbenv/versions/2.4.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/meltemi/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- /Users/meltemi/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/meltemi/.rbenv/versions/2.4.4/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/meltemi/.rbenv/shims
- /usr/local/heroku/bin
- .git/safe/../../bin
- /Users/meltemi/.bin
- /usr/local/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin

Related

Rails app is using wrong bundler version?

I've a Rails app that needs to use bundler version
gem "bundler", ">= 2.2.17", "<= 2.2.30"
I've installed bundler version 2.2.30 using gem install bundler:2.2.30 --default. Running gem list bundler returns the following
*** LOCAL GEMS ***
bundler (default: 2.2.30)
but the issue is that bundler version returns a different version(2.1.2) than 2.2.30. It returns
Bundler version 2.1.2
which bundler gives
/Users/masroor/.rbenv/shims/bundler
and whenever I try to bundle the app using bundle _2.2.30_ install or try running rails server/console, it does not pick up the right bundler version(2.2.30) instead it uses 2.1.2
Trying to do bundle _2.2.30_ install fails with this error
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (>= 2.2.17, <= 2.2.30)
Current Bundler version:
bundler (2.1.2)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running gem install bundler?
Could not find gem 'bundler (>= 2.2.17, <= 2.2.30)' in any of the relevant sources:
the local ruby installation
The gem env installation path does not contain the bundler gemspec against 2.1.2 bundler version.
Output of gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x86_64-darwin19]
- INSTALLATION DIRECTORY: /Users/masroor/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/masroor/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/masroor/.rbenv/versions/2.7.0/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/masroor/.rbenv/versions/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/masroor/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/masroor/.rbenv/versions/2.7.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-19
- GEM PATHS:
- /Users/masroor/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0
- /Users/masroor/.gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/masroor/.rbenv/versions/2.7.0/bin
- /usr/local/Cellar/rbenv/1.2.0/libexec
- /usr/local/opt/mysql#5.7/bin
- /Users/masroor/.rbenv/shims
- /Users/masroor/.nvm/versions/node/v10.16.3/bin
- /usr/local/opt/mysql#5.7/bin
- /Users/masroor/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Apple/usr/bin
- /Library/Apple/bin
The installed gemspecs for bundler, returned by ls /Users/masroor/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/specifications/default/ | grep bundler are
bundler-2.2.30.gemspec
I'm using rbenv for ruby version management, running ruby -v returns
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
which ruby returns
/Users/masroor/.rbenv/shims/ruby
I tried to find files pertaining to bundler 2.1.2 in my filesystem with
find / -type f -name bundler | grep bundler | grep 2.1.2
and found the following
/System/Volumes/Data/Users/masroor/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundler
/Users/masroor/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bundler-2.1.2/libexec/bundler
when I try to uninstall bundler version 2.1.2 with gem uninstall bundler:2.1.2 I get
Gem 'bundler' is not installed

Two versions of bundler installed and using the wrong one

I have the right version of Bundler installed:
docker#f5990915a8ae:/usr/src/app$ bundler version
Bundler version 2.2.17 (2021-05-05 commit 69cbd6e10e)
But when I run the db:migrate it seems that is using another one:
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.17). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.2.17.
This is my gem environment for the app:
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /home/docker/.gem
- USER INSTALLATION DIRECTORY: /home/docker/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/bin/ruby2.7
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /home/docker/.gem/bin
- SPEC CACHE DIRECTORY: /home/docker/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/docker/.gem
- /home/docker/.gem/ruby/2.7.0
- /var/lib/gems/2.7.0
- /usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0
- /usr/share/rubygems-integration/2.7.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/docker/.gem//bin
- /home/docker/.gem/ruby/2.7.0/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
These are the two bundler versions installed:
home/docker/.gem/specifications/bundler-2.2.17.gemspec
usr/lib/ruby/gems/2.7.0/specifications/default/bundler-2.1.4.gemspec
How do I make the db:migrate use the right one?
change to
bundle exec rake db:migrate
or change bundler version in Gemfile.lock

Running Ruby with Homebrew but cannot get Bundler to Work

Running bundle install I get the error: "-bash: bundle: command not found"
I can install Bundler with gem install bundler and I get no errors. In fact, if I run gem list it shows bundler (1.14.6). However, bundle -v or anything like that doesn't work.
I have uninstalled bundler and re-installed.
gem env returns:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.3 (2015-08-18 patchlevel 173) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.2.3/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /usr/local/Cellar/ruby/2.2.3/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/2.2.3/bin
- SPEC CACHE DIRECTORY: /Users/mike/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/Cellar/ruby/2.2.3/lib/ruby/gems/2.2.0
- /Users/mike/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/Cellar/ruby/2.2.3/bin/ruby
- /usr/local/bin/gem
brew doctor says "Your system is ready to brew"
echo $PATH says /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/ruby/2.2.3/bin/ruby:/usr/local/bin/gem
which gem returns: /usr/local/bin/gem
While this may not be a solution to your current issue, it is an alternative that could help you down the road in developing in Ruby / Rails.
I'd recommend moving to a ruby version control system such as RVM or rbenv where you then have full control over your ruby version on a per-project basis. It's much easier than playing with your system Ruby on OS X too. You'll probably find that once you have one of these installed, your bundler issues disappear.
Well, it's a little bit late answer, but I was able to do it like this:
gem install bundler -n /opt/homebrew/opt/ruby#2.5/bin
Where /opt/homebrew/opt/ruby#2.5/bin is a path where homebrew ruby installation gems is located

I can't run bundle it show bundle: command not found

I install bundle by using
sudo bundle install and sudo gem install bundler
It show error
bundle: command not found
I set path like this.
export PATH=$PATH:/var/lib/gems/1.8/bin
When I run command gem environment it show like this.
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.8
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- USER INSTALLATION DIRECTORY: /root/.gem/ruby/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
When I run command echo $PATH it show like this.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
How to fix error bundle: command not found ?
Simply hit the command
$gem install bundle
if the ruby version is required to updated do it separately
bundle(r) is a gem. I am guessing you have the gem not installed yet.
try
gem install bundler
Well, you're trying to install ruby as system package, and I would suggest not doing that since ruby 1.8 is very old version.
You should use rvm or rbenv instead for ruby installation.
Take a look on http://rvm.io. After rvm installed, install ruby
rvm install 2.3.1
then install bundler
gem install bundler

Bundle is installed, yet `-bash: bundle: command not found` when using any bundle command in app directory

I'm setting up a new Mac and trying to get dev environemnt set up. Using Homebrew & RVM as package managers. I have bundler installed when i run bundler -v from root it get Bundler version 1.13.6 no problem.
However I've just cloned one of my app projects locally and when in that app's directory bundler returns command not found. Surley I shouldn't need to install Bundler when in each directory?!? Is this some user permisisons issue? Can you help me understand this situation and why bundler doesn't work in the newly pulled app directory? Ultimately I'm just trying to bundle install the gemfile for this newly cloned application.
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/usr/.rvm/gems/ruby-2.2.2
- RUBY EXECUTABLE: /Users/usr/.rvm/rubies/ruby-2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/usr/rvm/gems/ruby-2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/usr/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/usr/.rvm/rubies/ruby-2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/usr/.rvm/gems/ruby-2.2.2
- /Users/usr/.rvm/gems/ruby-2.2.2#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/usr/.rvm/gems/ruby-2.2.2/bin
- /Users/usr/.rvm/gems/ruby-2.2.2#global/bin
- /Users/jusr/.rvm/rubies/ruby-2.2.2/bin
- /Users/usr/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
echo $PATH
/Users/usr/.rvm/gems/ruby-2.2.2/bin:/Users/usr/.rvm/gems/ruby-2.2.2#global/bin:/Users/usr/.rvm/rubies/ruby-2.2.2/bin:/Users/usr/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
which gem
/Users/usr/.rvm/rubies/ruby-2.2.2/bin/gem
You need to issue the following command:
rmv use 2.2.2

Resources