sudo msfconsole [*] Bundler failed to load and returned this error: help me - gemfile

┌─[alzaeem#Parrot]─[~/tools]
└──╼ $sudo msfconsole
[*] Bundler failed to load and returned this error:
'You have already activated bundler 2.1.4, but your Gemfile requires bundler 2.2.3. Since bundler is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports bundler as a default gem.'
[*] You may need to uninstall or upgrade bundler

you have to update your bundler version, in this case:
gem install bundler -v 2.2.3
for other gems
gem install 'gem name' -v 'version'

Related

bundler version claims to exist, but does not

How can this be explained and remedied?
-bash> gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.2.21)
-bash> bundler --version
Bundler version 2.1.4
-bash> gem uninstall bundler:2.1.4
Gem 'bundler' is not installed
-bash> gem environment | grep INSTALL
- INSTALLATION DIRECTORY: /Users/me/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/me/.gem/ruby/2.7.0
-bash> find /Users/me/.rbenv/versions/2.7.4/ -name "bundler*"
/Users/me/.rbenv/versions/2.7.4//bin/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/rubygems/bundler_version_finder.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/exe/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/cache/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/cache/bundler-2.2.21.gem
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/doc/bundler-2.2.21
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/doc/bundler-2.2.27
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bundler-2.2.21
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bundler-2.2.21/exe/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/rubocop-1.13.0/lib/rubocop/cop/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bootsnap-1.7.4/lib/bootsnap/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/rubocop-1.21.0/lib/rubocop/cop/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/simplecov-0.17.1/lib/simplecov/profiles/bundler_filter.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/bundler
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/LockfileParser/bundler_version-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/bundler_major_version-c.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Standalone/bundler_path-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Plugin/API/Source/bundler_plugin_api_source%3f-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Fetcher/bundler_cert_store-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/CLI/Gem/bundler_dependency_version-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/SharedHelpers/bundler_ruby_lib-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Gem/BundlerVersionFinder/bundler_version_with_reason-c.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Gem/BundlerVersionFinder/bundler_version-c.ri
I cannot explain it, but the remedy is:
Remove bundler-2.2.21.gemspec from the folder that renders it default:
Reinstall the desired version.
Uninstalling bundler will not work:
-bash> gem uninstall bundler
Gem bundler-2.2.21 cannot be uninstalled because it is a default gem
Note the following line in the output of the find command above:
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
Remove it in order to remove the "default" status of this gem:
rm /Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
Uninstalling is now impossible...
-bash> gem uninstall bundler
Gem 'bundler' is not installed
Indeed...
-bash> bundler --version
Traceback (most recent call last):
2: from /Users/me/.rbenv/versions/2.7.4/bin/bundler:23:in `<main>'
1: from /Users/me/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/Users/me/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /Users/me/Projects/kinside/kinside/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
So install the desired version:
-bash> gem install bundler:2.2.21
Successfully installed bundler-2.2.21
Parsing documentation for bundler-2.2.21
Installing ri documentation for bundler-2.2.21
Done installing documentation for bundler after 3 seconds
1 gem installed
Check:
-bash> bundler --version
Bundler version 2.2.21
-bash> gem list bundler
*** LOCAL GEMS ***
bundler (2.2.21)

How to fix "Warning: the running version of Bundler is older than the version that created the lockfile"

I have tried multiple times to uninstall bundler and reinstall bundler, and somehow, I keep seeing this error:
➜ gem uninstall bundler
Remove executables:
bundler
in addition to the gem? [Yn] y
Removing bundler
Successfully uninstalled bundler-2.0.1
➜ gem install bundler
Fetching: bundler-2.0.1.gem (100%)
Successfully installed bundler-2.0.1
1 gem installed
➜ bundle
Warning: the running version of Bundler (1.16.6) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Just uninstall and install again the required version in the warning, in your case it is requiring version 1.17.3
gem uninstall bundler
gem install bundler -v 1.17.3

after bundler installed with specific version why version of bundler did not change?

I got following error for bundle
Bundler could not find compatible versions for gem "bundler": In
Gemfile:
bundler (~> 1.15)
Current Bundler version:
bundler (2.0.1) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running gem install
bundler?
Could not find gem 'bundler (~> 1.15)' in any of the relevant sources:
the local ruby installation
then I tried to downgrade the bundler version with
$ gem install bundler -v '~> 1.7.0' Fetching: bundler-1.7.15.gem
(100%) Successfully installed bundler-1.7.15 Parsing documentation for
bundler-1.7.15 Installing ri documentation for bundler-1.7.15 Done
installing documentation for bundler after 1 seconds 1 gem installed
but when I recheck the bundler version with
bundler --version
it still said Bundler version 2.0.1
The default bundler version on your system is still 2.0.1. If you need to use the downloaded version 1.7.15, you would have to run bundle _1.7.15_ install. You could also check if that version was successfully installed on your system using bundle _1.7.15_ -v
In either case, if you get the error Could not find command "_1.7.15_", then that means that the bundler version _1.7.15_ has not been installed on your system.
Additionally, these links may help you:
Run specific version of bundler
Downgrade Bundler in RVM
Try updating bundle with bundler update bundler and run the bundle update again. It solved my problem the last time.

bundle install using wrong ruby with rvm when building native extension?

I'm using bundle install to install rest-client. It's failing with the following:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
I'm using rvm, which appears to be working correctly, if I'm reading the output from rvm info right.
which ruby reports /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby, which looks right.
I found Install ruby headers with rvm, but I have Ruby headers in (apparently) the correct place:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
In the output from bundle, I see /usr/bin/ruby2.3, which looks suspicious.
It's looking in the wrong place for Ruby header files. How do I get it to use the RVM-installed ones?
I was using the wrong bundle.
$ which bundle
/usr/bin/bundle
Either the one included in Ubuntu 16.04 is old, or using the system-installed bundler doesn't work with rvm-installed Ruby.
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/bin/bundle
That looks better.
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Lesson learned: when using rvm, remember to gem install bundler as well.

bson_ext 1.7.0 fails to build on Linux when using bundle:install Capistrano task

Here is the error message:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
Gem files will remain installed in /var/www/app_dir/shared/bundle/ruby/1.8/gems/bson_ext-1.7.0 for inspection.
Results logged to /var/www/app_dir/shared/bundle/ruby/1.8/gems/bson_ext-1.7.0/ext/cbson/gem_make.out
An error occured while installing bson_ext (1.7.0), and Bundler cannot continue.
Make sure that `gem install bson_ext -v '1.7.0'` succeeds before bundling.
I tried running gem install bson_ext -v '1.7.0' and this succeeded with no errors. I've tried installing ruby-dev and ruby1.8-dev apt packages and this did not help.
bundle install is able to successfully build bson_ext on my Mac OS X development system but is failing in the Linux production environment even when I run it directly outside of the context of the capistrano bundle:install task.
I have also tried running gem update --system and gem update bundler and this didn't help.
I suspect the issue lies in how bundle install is called on the target system. Still, I tried updating Capistrano to version 2.13.5 and this did not help.
So, it appears that bundler 1.2.1 is is unable to build the following gems on my system:
bson_ext 1.7.0
curb 0.8.3
nokogiri 1.5.5
json 1.7.5
therubyracer 0.8.2.
I was able to build these using gem install <GEMNAME> -v '<VERSION>' --install-dir /var/www/<APP_DIR>/shared/bundle/ruby/1.8/. After this, running bundle exec capistrano deploy succeeded.
bundle does not appear to be able to build gems with native extensions on my system. Not sure why, but maybe this procedure will help those with a similar issue.

Resources