Running Ruby with Homebrew but cannot get Bundler to Work - ruby-on-rails

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

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

MacOS: Ruby LoadError when trying to install Rails

I've already tried Googling everything; don't just point me towards the first few results you get when Google searching the same error.
This is what I've tried:
ruby 2.0 rails gem install error "cannot load such file -- openssl".
When I try to do gem install rails, I get this error. Frankly it happens when I try to gem install anything.
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Also, I should have Ruby 2.7.1 installed (I've installed it multiple times with brew, rbenv, and rvm), but when I do ruby -v it always returns ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]. I read somewhere that any Ruby version < 2.4 isn't compatible with OpenSSL 1.1. I need Ruby > 2.4.4 to install rails.
Here's my gem env
[14:21:23] jasper.huang ruby-2.7.1 gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/jasper.huang/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/jasper.huang/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/jasper.huang/.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/jasper.huang/Documents/School/USC/SPRING20/CSCI310/Project2/google-cloud-sdk/bin
- /Library/Frameworks/Python.framework/Versions/3.7/bin
- /usr/local/CrossPack-AVR/bin
- /Library/Frameworks/Python.framework/Versions/3.5/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/share/dotnet
- /opt/X11/bin
- ~/.dotnet/tools
- /Library/Frameworks/Mono.framework/Versions/Current/Commands
- /usr/local/CrossPack-AVR/bin
- /Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
- /Users/jasper.huang/.rvm/bin
I recently faced this issue and the problem was that ruby command was using core default ruby installation (i.e 2.3) instead of rvm ruby version. I am not sure how this happened but I faced this issue after I installed 'ohmyzsh' plugin. This is again a guess and I am not 100% sure if this plugin caused this issue.
So, I had to uninstall the plugin and re installed rvm and openssl package. Than, install the ruby version with openssl directory as parameter as suggested in the link you have shared.
You can also use the system installed openssl directory as well. Also try using this parameter while installing the gem '-- --with-opt-dir=/usr/local/opt/openssl'. The path should the openssl installed directory on your machine.
You need to make sure that you have rvm and ruby is installed and working fine by checking the ruby installed in rvm is activated in your machine. I hope this helps and please let me know if you have any further queries. Thank you.

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

Rails different versions in project folder and outside + Warning: You're using Rubygems 1.8.23 with Spring

I had big troubles with fixing RoR that works on my linux mint. Now when all seems to work fine, it doesn't. I'll describe it by c/p my terminal.
matth#MatijaComp /media/Data/My Documents/Sites $ rails -v
Rails 4.2.3
matth#MatijaComp /media/Data/My Documents/Sites $ cd mynewapp/
matth#MatijaComp /media/Data/My Documents/Sites/mynewapp $ rails -v
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Rails 4.2.1
Well.. Outside of project folder its 4.2.3 version and inside its 4.2.1 version with warning. I was trying to remove this warning by stopping spring spring stop , but nothing happens..And when I try to update Rubygems it says that I have already the newest version.
Then my question is if someone would like to explain me why those versions aren't synchronized and guide me to fix this problem. Thank you!
Update
I fixed rails version, but problem still appears on this warning. when I type gem env it says:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/matth/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /home/matth/.rbenv/versions/2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /home/matth/.rbenv/versions/2.2.2/bin
- SPEC CACHE DIRECTORY: /home/matth/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/matth/.rbenv/versions/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/matth/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /home/matth/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/matth/.rbenv/versions/2.2.2/bin
- /home/matth/.rbenv/libexec
- /home/matth/.rbenv/plugins/ruby-build/bin
- /home/matth/.rbenv/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/local/mysql/bin
- /home/matth/.rbenv/shims
- /home/matth/.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/matth/bin
- /usr/local/java/jdk1.8.0_45/bin
- /home/matth/bin
- /usr/local/java/jdk1.8.0_45/bin
Now, which ever action I do with rails command in my project folder it gives me this warning. IN ADDITION, I figured out that commands even don't work. it just appears this:
matth#MatijaComp /media/Data/My Documents/Sites/myfourthapp $ rails generate controller demo index
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
matth#MatijaComp /media/Data/My Documents/Sites/myfourthapp $
I have "fixed" problem temporary by commenting gem 'spring' in Gemfile. But it is not the way out of this problem.
Rails is just a gem. Among with other gems in the project, it is managed by bundler on a per-project basis.
If you need to change gem version, just specify it in the Gemfile, and run bundle install.

Bundler / Rails cannot find newly installed Gems

I have searched around quite a bit here already to ensure that this question has not been asked previously. While there have been a plethora of similar cases, I was not able to find anyone else experiencing my situation.
My situation is that Rails / Bundler cannot find any reference to my newly installed Gems. In this instance, Nokogiri.
This is the error I am getting when trying to run bundle install
Could not find gem 'nokogori (>= 0) ruby' in the gems available on this machine.
This is a brand new install of OS X Yosemite, so I think a core step may have just been missed somewhere?
I have used Thoughtbots "Laptop" script to install all of my dev stuff because there's a tonne of overlap with my usual tools, plus installed Rails after that.
https://github.com/thoughtbot/laptop
Here are the steps I am taking to reproduce the error
Install Nokogiri
Lukes-MBP% gem install nokogiri
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.6.2
Parsing documentation for nokogiri-1.6.6.2
Done installing documentation for nokogiri after 2 seconds
1 gem installed
Add to Gemfile
gem 'nokogori'
Ensure it's installed
Lukes-MBP% whereis nokogiri
/usr/bin/nokogiri
And here is my gem environment output
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.0 (2014-12-25 patchlevel 0) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/lukerollans/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /Users/lukerollans/.rbenv/versions/2.2.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/lukerollans/.rbenv/versions/2.2.0/bin
- SPEC CACHE DIRECTORY: /Users/lukerollans/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/lukerollans/.rbenv/versions/2.2.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/lukerollans/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0
- /Users/lukerollans/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/lukerollans/.rbenv/versions/2.2.0/bin
- /usr/local/Cellar/rbenv/0.4.0/libexec
- /Users/lukerollans/.rbenv/shims
- /usr/local/bin
- /Users/lukerollans/.bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
This has been bugging me for hours now, so if anyone can shed any light on what I'm doing wrong, that would be super!
Try checking your ruby version using
$ rvm list
to check your ruby version, and then change to proper ruby version using
$ rvm use 2.2.0
then install nokogiri using
$ gem install nokogiri

Resources