Two versions of bundler installed and using the wrong one - ruby-on-rails

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

Related

Changing gem env

I am new to Using changing ruby and have been having a lot of trouble getting it to version 2.7.6 so that I can install the react native CLI. Previously I changed it to 2.7.5 thinking that would work, but it didn't. I am not sure how I did this. The reason I need 2.7.6 is so that I can install the bundler for cocoa pods for IOS. Here is the gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.6
- RUBY VERSION: 2.7.5 (2021-11-24 patchlevel 203) [x86_64-darwin22]
- INSTALLATION DIRECTORY: /Users/jonnywerthman/.rvm/gems/ruby-2.7.5
- USER INSTALLATION DIRECTORY: /Users/jonnywerthman/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/jonnywerthman/.rvm/rubies/ruby-2.7.5/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/jonnywerthman/.rvm/gems/ruby-2.7.5/bin
- SPEC CACHE DIRECTORY: /Users/jonnywerthman/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jonnywerthman/.rvm/rubies/ruby-2.7.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-22
- GEM PATHS:
- /Users/jonnywerthman/.rvm/gems/ruby-2.7.5
- /Users/jonnywerthman/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jonnywerthman/.rvm/gems/ruby-2.7.5/bin
- /Users/jonnywerthman/.rvm/gems/ruby-2.7.5#global/bin
- /Users/jonnywerthman/.rvm/rubies/ruby-2.7.5/bin
- /Users/jonnywerthman/.rbenv/shims
- /Users/jonnywerthman/opt/miniconda3/bin
- /Users/jonnywerthman/opt/miniconda3/condabin
- /Library/Frameworks/Python.framework/Versions/3.10/bin
- /usr/local/bin
- /System/Cryptexes/App/usr/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin
- /Library/Apple/usr/bin
- /Users/jonnywerthman/.rvm/bin
I need to make sure that it is switched to 2.7.6 and that the react native CLI actually reads it as 2.7.6 so that I can download the stuff I need.
I recommend using rbenv.
https://github.com/rbenv/rbenv
It is less intrusive than rvm.

Bunder is installing with rubygems dependency not version in gem directory

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

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

Gems not found because installed in different locations

I have some gems that are not being found b/c I think they are installed in the wrong location. How can I fix this? My setup:
which gem allure-cucumber
/Users/qahq/.rvm/rubies/ruby-2.1.0/bin/gem
which gem cucumber
/Users/qahq/.rvm/rubies/ruby-2.1.0/bin/gem
/Users/qahq/.rvm/gems/ruby-2.1.0#idme-revelator/bin/cucumber
rvm gemset name
idme-revelator
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin14.0]
- INSTALLATION DIRECTORY: /Users/qahq/.rvm/gems/ruby-2.1.0#idme-revelator
- RUBY EXECUTABLE: /Users/qahq/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/qahq/.rvm/gems/ruby-2.1.0#idme-revelator/bin
- SPEC CACHE DIRECTORY: /Users/qahq/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/qahq/.rvm/rubies/ruby-2.1.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/qahq/.rvm/gems/ruby-2.1.0#idme-revelator
- /Users/qahq/.rvm/gems/ruby-2.1.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/qahq/.rvm/gems/ruby-2.1.0#idme-revelator/bin
- /Users/qahq/.rvm/gems/ruby-2.1.0#global/bin
- /Users/qahq/.rvm/rubies/ruby-2.1.0/bin
- /Users/qahq/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
allure
-bash: allure: command not found
I'm guessing the allure command isn't working b/c it's not in the proper directory that cucumber is in, b/c the cucumber command works.
How can I fix this?
Try running it with bundle exec rails server

Trouble to bundle install some gems on production server

I find some trouble to bundle install some gems like nokogiri, eventmachine, json, http_parser.rb, yajl-ruby on production server.
I use capistrano to deploy the app,
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/deployer/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
Results logged to /home/deployer/apps/yanny/shared/bundle/ruby/2.0.0/gems/gemname/ext/gem_make.out
Make sure that gem install X succeeds before bundling.
if i try to install missing gem through server it works and bundle install stops asking for it:
gem install x -v y --install-dir /home/deployer/apps/holo/shared/bundle/ruby/2.0.0/
here is my gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 2.1.11
- RUBY VERSION: 2.0.0 (2013-11-22 patchlevel 353) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/deployer/.rvm/gems/ruby-2.0.0-p353
- RUBY EXECUTABLE: /home/deployer/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
- EXECUTABLE DIRECTORY: /home/deployer/.rvm/gems/ruby-2.0.0-p353/bin
- SPEC CACHE DIRECTORY: /home/deployer/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/deployer/.rvm/gems/ruby-2.0.0-p353
- /home/deployer/.rvm/gems/ruby-2.0.0-p353#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/deployer/.rvm/gems/ruby-2.0.0-p353/bin
- /home/deployer/.rvm/gems/ruby-2.0.0-p353#global/bin
- /home/deployer/.rvm/rubies/ruby-2.0.0-p353/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
Any ideas ?

Resources