I can't run bundle it show bundle: command not found - ruby-on-rails

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

Related

Ruby Version Incorrect

I think I've got a simple problem but I've spent hours searching for the answer. It's taken me a while to get the correct version of ruby installed and recognized when running ruby -v (it had previously been v2.5.1, but for some reason I still can't use the command bundle install. It tells me I've got the wrong version of ruby... but this doesn't appear to be true???
I am trying to deploy a Ruby on Rails repository to an EC2 instance.
Any help would be much appreciated! Thanks in advance.
I have ran these commands from within my repository directory:
ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
bundle install
Your Ruby version is 2.5.1, but your Gemfile specified 2.5.3
.bashrc and .bash_profile have the following commands in them:
export PATH="$HOME/.rbenv/bin:~/.rbenv/shims:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Available versions:
~/.rbenv/versions$ ls
2.5.3
irb
irb(main):001:0> RUBY_VERSION
=> "2.5.3"
rbenv version
2.5.3 (set by /home/ubuntu/.rbenv/version)
whereis ruby
ruby: /usr/bin/ruby
/usr/bin/ruby2.5
/usr/lib/x86_64-linux-gnu/ruby
/usr/lib/ruby
/home/ubuntu/.rbenv/shims/ruby
/snap/bin/ruby.rake /snap/bin/ruby.bundle
/snap/bin/ruby.gem
/snap/bin/ruby.env
/snap/bin/ruby.rdoc
/snap/bin/ruby
/snap/bin/ruby.irb
/snap/bin/ruby.ri
/usr/share/man/man1/ruby.1.gz
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /home/ubuntu/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /home/ubuntu/.rbenv/versions/2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/bin
- SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/ubuntu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- /home/ubuntu/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "“gem" => "--no-document”"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/ubuntu/.rbenv/versions/2.5.3/bin
- /home/ubuntu/.rbenv/libexec
- /home/ubuntu/.rbenv/plugins/ruby-build/bin
- /home/ubuntu/.rbenv/shims
- /home/ubuntu/.rbenv/bin
- ~/.rbenv/shims
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local
You can try to force an update to your Ruby version in the Gemfile.lock:
bundle update --ruby in the same folder as the Gemfile.
If that didn't work you could also try a:
gem install bundler
Making sure you're in a directory/project that is using ruby 2.5.3 (i.e double check with ruby -v).
Finally you can do a manual rbenv rehash to check it's up-to-date:
rbenv rehash

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

Why do I get this error Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2

I followed the instructions and thoughts raised in this question: "Why do I get the error “Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2” although I have 2.2.2 installed 2"
I have the same error after problems with /User folder when a script removed the folders preceding with "." which included the .rbenv folder.
After a rebuild of rails, rbenv and such. Im still getting the error from rails
"Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2"
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/chris/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /Users/chris/.rbenv/versions/2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/chris/.rbenv/versions/2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/chris/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/chris/.rbenv/versions/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/chris/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /Users/chris/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "-n/usr/local/bin"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/chris/.rbenv/versions/2.2.2/bin
- /usr/local/Cellar/rbenv/0.4.0/libexec
- /Users/chris/.rbenv/shims
- /Users/chris/.rbenv/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/local/mysql/bin
- /Library/PostgreSQL/9.4/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Here is the current version:
$ rbenv versions
system
* 2.2.2 (set by /Users/chris/Dropbox/git/frontend.1/.ruby-version)
2.2.3
Current .bash_profile
PS1="\u$ "
alias ll="ls -lahG"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Library/Postg$
export PATH="$HOME/.rbenv/bin:$PATH"
I tried this:
gem install --no-ri --no-rdoc bundler
rbenv rehash
bundle --path=vendor/bundle
But it did not fix or change the error.
Your bash init script looks like you didn't finish installing rbenv correctly. First of all, it seems that you've installed rbenv with Homebrew. That's OK, but you should update it before you proceed:
brew update && brew upgrade rbenv
If you installed with Homebrew, then you don't need this line in your .bash_profile
# remove this line
export PATH="$HOME/.rbenv/bin:$PATH"
However, you need to add this line to the end of your .bash_profile:
# add this line
eval "$(rbenv init -)"
Now, open a new terminal window, then
rbenv version #=> 2.2.2
gem i bundler --no-rdoc -no-ri
which bundle #=> ~/.rbenv/shims/bundle
Now you can run bundle install in your project.

RubyMine Using Incorrect/Different Ruby Version - Ubuntu

I'm on an Ubuntu system and have installed ruby-2.1.3 using rbenv. I have made 2.1.3 global and it is accessible from my system terminal.
System Terminal:
lambda#lambda-PC:~$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
However, when I run the same command in my RubyMine embedded terminal, it asks me to install ruby through the aptitude repository.
lamdba#lambda-PC:~/RubymineProjects/Loccasions$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
The same thing goes for "gem environment" and "gem -v".
System Terminal:
lambda#lambda-PC:~$ gem -v
2.4.2
lambda#lambda-PC:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.2
- RUBY VERSION: 2.1.3 (2014-09-19 patchlevel 242) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/lambda/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /home/lambda/.rbenv/versions/2.1.3/bin/ruby
- EXECUTABLE DIRECTORY: /home/lambda/.rbenv/versions/2.1.3/bin
- SPEC CACHE DIRECTORY: /home/lambda/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/lambda/.rbenv/versions/2.1.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/lambda/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0
- /home/lambda/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/lambda/.rbenv/versions/2.1.3/bin
- /home/lambda/.rbenv/libexec
- /home/lambda/.rbenv/plugins/ruby-build/bin
- /home/lambda/.rbenv/shims
- /home/lambda/.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
RubyMine Terminal:
lambda#lambda-PC:~/RubymineProjects/Loccasions$ gem -v
The program 'gem' can be found in the following packages:
* ruby
* rubygems
Try: sudo apt-get install <selected package>
lambda#lambda-PC:~/RubymineProjects/Loccasions$ gem environment
The program 'gem' can be found in the following packages:
* ruby
* rubygems
Try: sudo apt-get install <selected package>
I have sifted through all of the settings that I'm aware of in RubyMine that relate to the SDK, and have directed them the ruby-2.1.3 stored in rbenv. I have done much research on this topic, but my attempts are futile. I would appreciate help in diagnosing this error.
I added $HOME/.rbenv/shims to my path through
export PATH="$HOME/.rbenv/shims:$PATH"
And it works!

Error while gem install on ubuntu 12.04 aws ec2

I got a Ubuntu 12.04 instance in AWS EC2.
I just want to gem install rails.
But it shows this error message.
Is this caused by the difference gem env between sudo gem env?
Is there any ways to solve this problem except rvm implode?
What's the risk of using rvmsudo instead?
Fetching: atomic-1.1.15.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby-1.9.3-p545#global directory.
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 1.9.3 (2014-02-24 patchlevel 545) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p545#global
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p545/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p545#global/bin
- SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-1.9.3-p545#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/rvm/gems/ruby-1.9.3-p545#global/bin
- /usr/local/rvm/rubies/ruby-1.9.3-p545/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/rvm/bin
sudo gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/ubuntu/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://rubygems.org/
rvm is made to be used without sudo or specific/sudo rights.
reinstall would be more appreciated.
clean the current rvm install
rvmsudo rvm implode
sudo rm -rf /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm
and then close all consoles/bashes/terminales and login in again with the user you want to use rvm with and install it again.
Is this caused by the difference gem env between sudo gem env?
Quite possibly, the rvm Ruby is separate and different from the system Ruby environment and depends on where what gem gets executed according to the path.
However, it looks like you are running an rvm Ruby gem install as a different user as the owner of /usr/local/rvm/gems and it's subdirectories, which is supposed to be installed as rvmsudo
What user are you running the rvm gem install as?
You can try this:
chown -R user-you-want-to-run-command-as.user-you-want-to-run-command-as /usr/local/rvm/gems
Or also try like you mentioned rvmsudo. The risk there as the some of the files may have root ownership which you may not want if you want to be more secure.
Note that rvmsudo is not the recommended way but rather use rvm on your local directory. If you'd like to remove it you can do this:
rvmsudo rvm implode
sudo rm -rf /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm
Then reinstall with just rvm

Resources