Rails app is using wrong bundler version? - ruby-on-rails

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

Related

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

How to add to gem file in Ruby?

I am getting started on Rails and I am trying to rectify my issue of "ExecJS::ProgramError in Pages#home" while setting up first page as suggested below
downgrading the gem coffee-script-source' from 1.9.1 to 1.8.0
But to which gem file should I add? I see a whole of folders under the GEM PATHS as shown by the result of the command GEM ENV
Also when I run from the command line I get the below error( I assume this is not the way to do it)
C:\Sites\myrails\App>gem coffee-script-source 1.8.0
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command coffee-script-source
Any help would be really appreciated?
My Rails env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.7
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: C:/RailsInstaller1.0/Ruby2.1.0/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/RailsInstaller1.0/Ruby2.1.0/bin
- SPEC CACHE DIRECTORY: C:/Users/baskaran/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0
- C:/Users/baskaran/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\RailsInstaller1.0\Git\cmd
- C:\RailsInstaller1.0\Ruby2.1.0\bin
- C:\RailsInstaller1.0\Ruby2.1.0\lib\ruby\gems\1.9.1\bin
- C:\RailsInstaller1.0\DevKit\bin
As per the suggestion - tried to do the following
C:\Sites\myrails\App>gem install coffee-script-source -v 1.8.0
Successfully installed coffee-script-source-1.8.0
Parsing documentation for coffee-script-source-1.8.0
Installing ri documentation for coffee-script-source-1.8.0
Done installing documentation for coffee-script-source after 0 seconds
1 gem installed
But still getting the below when trying to access localhost:3000/pages/home
TypeError: Object doesn't support this property or method
(in C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Generally these things are managed via the Gemfile. If you need to downgrade:
gem 'coffee-script-source', '1.8.0'
Then do bundle install.
Remember the command you're looking for to do a manual install is:
gem install coffee-script-source -v 1.8.0
I think I solved by this editing the Gemfile in my app directory to add
gem 'coffee-script-source', '1.8.0'
and then run
bundle install coffee-script-source
Thanks

"gem install bundler" won't work with a project that includes a gemset(rvm) in Mac OS x 10.8.1

My problem is summarized in the following lines:
Joses-MacBook-Pro:~ jose$ cd Estate/
Using /Users/jose/.rvm/gems/ruby-1.9.2-p290 with gemset realstate
Joses-MacBook-Pro:Estate jose$ bundle
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Joses-MacBook-Pro:Estate jose$ gem install bundler
Successfully installed bundler-1.2.1
1 gem installed
Installing ri documentation for bundler-1.2.1...
Installing RDoc documentation for bundler-1.2.1...
Joses-MacBook-Pro:Estate jose$ bundle
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Joses-MacBook-Pro:Estate jose$
Here's the output for my Gem Env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin12.1.0]
- INSTALLATION DIRECTORY: /Users/jose/.rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /Users/jose/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jose/.rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/jose/.rvm/gems/ruby-1.9.3-p194
- /Users/jose/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I've tried to solve this problem by using many answers I've seen around here, like:
Ruby: "gem install bundler" not installing bundler
But unfortunately so far I've not been able to solve the problem, I hope somebody can help me out figuring this out. I'm a Mac OS X newcomer.
Thanks in advance !
EDIT:
which bundle:
Joses-MacBook-Pro:Estate jose$ which bundle
/Users/jose/.rvm/bin/bundle
$(which bundle)
which gem, etc
Joses-MacBook-Pro:Estate jose$ which gem || type gem | head -n 1
/Users/jose/.rvm/bin/gem
Joses-MacBook-ProEstate jose$ hash -r
Joses-MacBook-Pro:Estate jose$
you need to explicitly use ruby:
rvm use 1.9.3

bundle install -jailshell: bundle: command not found on shared hosting

Bundle install is not working on shared hosting , but i installed gem bundle , when i ran the following command
i tried
bundle install
-jailshell: bundle: command not found
so i try to evaluate the following commands
gem list bundler -v 1.1.4
*** REMOTE GEMS ***
bundler (1.1.4)
bundler-auto-update (0.0.4)
bundler-bootstrap (0.0.3)
bundler-bouncer (0.1.2)
bundler-fastupdate (0.0.3)
bundler-github (0.2.0)
bundler-maglev- (1.0.21)
bundler-talks (0.0.4)
bundler08 (0.8.5)
bundler_bash_completion (0.1.1)
bundler_geminabox (0.0.1)
bundler_local_development (0.3.0)
bundler_push_host (0.0.1)
bundler_timer (1.1.2)
bundler has installed , but i don't know why its not working?
when i ran
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/username/ruby/gems
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home/username/ruby/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/username/ruby/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gempath" => []
- "gem" => "--remote --gen-rdoc --run-tests"
- "gemhome" => "/home/username/ruby/gems"
- "rdoc" => "--inline-source --line-numbers"
- REMOTE SOURCES:
- http://rubygems.org/
echo $PATH
/usr/local/jdk/bin:/home/username/perl5/bin:/usr/kerberos/bin:/usr/lib/courier-imap/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/username/bin
uname -mrsn
Linux osprey.arvixe.com 2.6.18-374.3.1.el5.lve0.8.44 x86_64
more /proc/version
Linux version 2.6.18-374.3.1.el5.lve0.8.44 (mockbuild#buildfarm.cloudlinux.com)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)) #1 SMP Mon Oct 3 18:27:54 EEST 2
011
which gem
/usr/bin/gem
which ruby
/usr/bin/ruby
which rails
/usr/bin/rails
ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
rails -v
Rails 2.3.14
gem -v
1.8.15
locate bundle
locate: can not open `/var/lib/mlocate/mlocate.db': Permission denied
Guys Please help me basic bundle install command is not working , so i don't know what todo and also i am new to ruby on rails.
I solved my problem, hosting guys need to give some permissions.
you always need to install gems on our home directory particularly in shared hosting
bundle install --path /home/username/bundle

"gem install bundler --version=0.8.1" doesn't install the bundle executable

When trying to install Bundler 0.8.1 on Ubuntu machine, it install fine but the executable "bundle" is no where to be seen. Other gems install successfully, including their executables.
using: gem install bundler --version=0.8.1
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
- INSTALLATION DIRECTORY: /home/ahammad/gems
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /home/ahammad/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/ahammad/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gem1.gilt.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Path /home/ahammad/gems/bin has been added to PATH, the problem is there is no bundle exe.
Any ideas?
Maybe that specific version of bundler wasn't available for installation, so to choose specific available range of versions which could be available, try:
gem install bundler --version '<= 0.10.6'
Or simple uninstall the previous bundler and install it again. Then check by gem list bundler or bundler _0.9.26_ -v (where 0.9.26 is version of your older gem).
Check also the permissions of your local gem folders.
Learn more: How to upgrade/downgrade Rubygems at rubyforge
That might be. I've used only 1.0. But I had the same problem. A tutorial assumed I could run "bundle". It was fixed only after following the directions here
http://lindsaar.net/2010/3/31/bundle_me_some_sanity
The directions involve installing rvm and creating an app directory with a .rvmrc file among other things.
Then in that directory you can run "bundle".
The binary is ~/.rvm/gems/ruby-1.8.7-p302#railsplugins/bin/bundle
apparently 0.8.1 uses "gem bundle" rather than "bundle"

Resources