Can't create a rails project after installing rails.
Mac Mojave 10.14.6
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
$ which ruby
/usr/local/opt/ruby/bin/ruby
$ gem -v
3.1.2
$ sudo gem install rails
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
Then tried to create a rails project
$ rails new blah
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
$ which rails
/usr/bin/rails
Any ideas why I can't create a rails project as rails seems to be installed?
$ 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/shanegibney/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/shanegibney/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/shanegibney/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.1/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:
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /usr/local/opt/ruby/bin
- /opt/local/bin
- /opt/local/sbin
- /opt/local/bin
- /opt/local/sbin
- /usr/local/sbin
- /usr/local/mysql/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin
- /opt/X11/bin
- /Library/Frameworks/Mono.framework/Versions/Current/Commands
- /opt/ImageMagick/bin
- /Applications/Wireshark.app/Contents/MacOS
Then,
$ /usr/bin/rails new blah
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
-bash: tail: command not found
-bash: sed: command not found
Also tried,
$ export PATH="/usr/bin/rails" >> ~/.bash_profile
-bash: tail: command not found
-bash: sed: command not found
Thanks,
Related
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
I try to update gem in my macOS but the following error occurs:
$ RUBYOPT= gem update --system
ERROR: While executing gem ... (NoMethodError)
undefined method `ssl_version=' for #<OpenSSL::SSL::SSLContext:0x007f8561047638>
Did you mean? ssl_timeout=
The output of gem update and gem install {package_name} are the same.
The output of gem env version or gem --version is:
3.0.3
The output of openssl version is:
LibreSSL 2.6.5
How can I resolve the issue?
macOS version: 10.14.4
Output of gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/adv/.rvm/gems/ruby-2.4.0
- USER INSTALLATION DIRECTORY: /Users/adv/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/adv/.rvm/rubies/ruby-2.4.0/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/adv/.rvm/gems/ruby-2.4.0/bin
- SPEC CACHE DIRECTORY: /Users/adv/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/adv/.rvm/rubies/ruby-2.4.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/adv/.rvm/gems/ruby-2.4.0
- /Users/adv/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/adv/.rvm/gems/ruby-2.4.0/bin
- /Users/adv/.rvm/gems/ruby-2.4.0#global/bin
- /Users/adv/.rvm/rubies/ruby-2.4.0/bin
- /Users/adv/.fastlane/bin
- /Library/Frameworks/Python.framework/Versions/3.7/bin
- /usr/local/sbin
- /Users/adv/.rbenv/shims
- /Users/adv/.rvm/bin
- /Users/adv/.fastlane/bin
- /Library/Frameworks/Python.framework/Versions/3.7/bin
- /usr/local/sbin
- /Users/adv/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/share/dotnet
- /Library/Frameworks/Mono.framework/Versions/Current/Commands
- /Users/adv/android-sdks/platform-tools
- /Users/adv/android-sdks/tools
- /opt/metasploit-framework/bin
- /opt/metasploit-framework/bin
- /Users/adv/android-sdks/platform-tools/
- /Users/adv/android-sdks/tools/
- /opt/metasploit-framework/bin
- /opt/metasploit-framework/bin
Output of which gem:
/Users/adv/.rvm/rubies/ruby-2.4.0/bin/gem
Output of rbenv versions:
system
* 2.4.1 (set by /Users/adv/.rbenv/version)
Output of ruby -ropenssl -e "puts OpenSSL::OPENSSL_LIBRARY_VERSION":
OpenSSL 1.1.1b 26 Feb 2019
Output of rvm list:
=* ruby-2.4.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
UPDATE: After I removed rvm and rbenv completely (and restarted the Terminal session), I try to execute gem update again, here is the result:
$ gem update
Updating installed gems
Updating CFPropertyList
Fetching: CFPropertyList-3.0.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
I think it now uses macOS's system ruby again.
Here are some outputs:
Output of gem -v:
2.5.2.3
Output of ruby -v:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Output of which gem:
/usr/bin/gem
Ouput of which ruby:
/usr/bin/ruby
My aim is to use gem without problems (install & update, etc). What should I do next?
OpenSSL::SSL::SSLContext#ssl_version= appeared in ruby 1.8.7, mac os has 2.3.7 built-in
Just checked on 10.14.2 -
require 'openssl'; OpenSSL::SSL::SSLContext.new.ssl_version="TLSv1"
works fine even on system ruby, OpenSSL versions are the same as yours.
The only thing left to suspect is rbenv conflict with rvm, because you have both installed, it may mess loaded libraries and ruby compilation. I suggest removing one of them completely (also not forget to start new shell session after this) and reinstall broken ruby.
I do not have RVM installed. I want to install ruby 2.5.1. When I install RVM with "rvm install ruby-2.5.1", I get the error: "-bash: rvm: command not found".
My default ruby version in my iMac is 2.3.3
When I run "ruby -v" I'm getting this,
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
But the latest version is 2.5.1
When I try to install rvm it's getting this message.
NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.
I tried these to solve my problem URL's to solve, but no use.
http://railsapps.github.io/installrubyonrails-mac.html
https://www.ruby-lang.org/en/downloads/
https://blog.arkency.com/which-ruby-version-am-i-using-how-to-check/
When I enter "gem env"
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [universal.x86_64-darwin17]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/research/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/research/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-17
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/research/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.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
Finally i updated successfully with the help of these links...
https://www.computersnyou.com/5307/setup-homebrew-and-rvm-on-mac-osx-10-11-ei-capitan/
I typed this command,
\curl -sSL https://get.rvm.io | bash -s stable
After that i used this command,
type rvm | head -n 1
It's printing "rvm is a function"
After that i used this command,
rvm install ruby-head
After some time RVM installed.
When i type this command
ruby -v
I'm getting this message "ruby 2.6.0dev (2018-05-16 trunk 63444) [x86_64-darwin17]"
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
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!