1

Using Ubuntu 20.04

(1. Problem
2. What I tried so far
3. Commands for all installations
4. gem env
5. local gems
6. list of PATH folders)

  1. Problem:
$ rails -v

Command 'rails' not found, but can be installed with:

sudo apt install ruby-railties
  1. What I tried so far

-bash: rails: command not found When I use 'bundle exec rails c' I get 'Could not locate Gemfile or .bundle/ directory'

rails rbenv: rails: command not found I used 'rbenv rehash' in the installation

rbenv: rails: command not found immediately after installing rails 5.2.1 'gem pristine --all', showed no effect

  1. Commands for all installations (all went successfull without any errors)
### INSTALLATION HOMEBREW FOR LINUX ###


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

### INSTALLATION OF RUBY, GIT, SQLITE3, NVM, NODEJS, YARN, BUNDLER, RAILS ###

rbenv install 2.6.6 && rbenv global 2.6.6

brew install git

brew install sqlite3

brew install nvm

nvm install 12.16.2 && nvm alias default 12.16.2 && nvm use default

npm install -g yarn

gem install bundler && gem install rails -v 6.0.2.2
  1. gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.2
  - RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/linuxbrew/.linuxbrew/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: /home/chris/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /home/linuxbrew/.linuxbrew/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /home/linuxbrew/.linuxbrew/bin/git
  - EXECUTABLE DIRECTORY: /home/linuxbrew/.linuxbrew/lib/ruby/gems/2.7.0/bin
  - SPEC CACHE DIRECTORY: /home/chris/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /home/linuxbrew/.linuxbrew/Cellar/ruby/2.7.1_3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/linuxbrew/.linuxbrew/lib/ruby/gems/2.7.0
     - /home/chris/.gem/ruby/2.7.0
     - /home/linuxbrew/.linuxbrew/Cellar/ruby/2.7.1_3/lib/ruby/gems/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/chris/.nvm/versions/node/v12.16.2/bin
     - /home/chris/anaconda3/bin
     - /home/chris/anaconda3/condabin
     - /home/linuxbrew/.linuxbrew/bin
     - /home/linuxbrew/.linuxbrew/sbin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin
  1. local gems (rails (6.0.2.2) exists!)
### gem list --local ###

*** LOCAL GEMS ***

actioncable (6.0.2.2)
actionmailbox (6.0.2.2)
actionmailer (6.0.2.2)
actionpack (6.0.2.2)
actiontext (6.0.2.2)
actionview (6.0.2.2)
activejob (6.0.2.2)
activemodel (6.0.2.2)
activerecord (6.0.2.2)
activestorage (6.0.2.2)
activesupport (6.0.2.2)
benchmark (default: 0.1.0)
bigdecimal (default: 2.0.0)
builder (3.2.4)
bundler (2.1.4, default: 2.1.2)
cgi (default: 0.1.0)
concurrent-ruby (1.1.6)
crass (1.0.6)
csv (default: 3.1.2)
date (default: 3.0.0)
delegate (default: 0.1.0)
did_you_mean (default: 1.4.0)
erubi (1.9.0)
etc (default: 1.1.0)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.4.1)
forwardable (default: 1.3.1)
getoptlong (default: 0.1.0)
globalid (0.4.2)
i18n (1.8.2)
io-console (default: 0.5.6)
ipaddr (default: 1.2.2)
irb (default: 1.2.3)
json (default: 2.3.0)
logger (default: 1.4.2)
loofah (2.5.0)
mail (2.7.1)
marcel (0.3.3)
matrix (default: 0.2.0)
method_source (1.0.0)
mimemagic (0.3.4)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
mutex_m (default: 0.1.0)
net-pop (default: 0.1.0)
net-smtp (default: 0.1.0)
net-telnet (0.2.0)
nio4r (2.5.2)
nokogiri (1.10.9)
observer (default: 0.1.0)
open3 (default: 0.1.0)
openssl (default: 2.1.2)
ostruct (default: 0.2.0)
power_assert (1.1.7)
prime (default: 0.1.1)
pstore (default: 0.1.0)
psych (default: 3.1.0)
racc (default: 1.4.16)
rack (2.2.2)
rack-test (1.1.0)
rails (6.0.2.2)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.3.0)
railties (6.0.2.2)
rake (13.0.1)
rdoc (default: 6.2.1)
readline (default: 0.0.2)
readline-ext (default: 0.1.0)
reline (default: 0.1.3)
rexml (default: 3.2.3)
rss (default: 0.2.8)
sdbm (default: 1.0.0)
singleton (default: 0.1.0)
sprockets (4.0.0)
sprockets-rails (3.2.1)
stringio (default: 0.1.0)
strscan (default: 1.0.3)
test-unit (3.3.4)
thor (1.0.1)
thread_safe (0.3.6)
timeout (default: 0.1.0)
tracer (default: 0.1.0)
tzinfo (1.2.7)
uri (default: 0.10.0)
webrick (default: 1.6.0)
websocket-driver (0.7.1)
websocket-extensions (0.1.4)
xmlrpc (0.3.0)
yaml (default: 0.1.0)
zeitwerk (2.3.0)
zlib (default: 1.1.0)

6.list of PATH folders

### /home/linuxbrew/.linuxbrew/lib/ruby/gems/2.7.0$ ls ####

bin  build_info  cache  doc  extensions  gems  specifications



### /home/linuxbrew/.linuxbrew/lib/ruby/gems/2.7.0/gems$ ls ###

actioncable-6.0.2.2    i18n-1.8.2           rails-6.0.2.2
actionmailbox-6.0.2.2  irb-1.2.3            rails-dom-testing-2.0.3
actionmailer-6.0.2.2   loofah-2.5.0         rails-html-sanitizer-1.3.0
actionpack-6.0.2.2     mail-2.7.1           railties-6.0.2.2
actiontext-6.0.2.2     marcel-0.3.3         rake-13.0.1
actionview-6.0.2.2     method_source-1.0.0  rdoc-6.2.1
activejob-6.0.2.2      mimemagic-0.3.4      sprockets-4.0.0
activemodel-6.0.2.2    mini_mime-1.0.2      sprockets-rails-3.2.1
activerecord-6.0.2.2   mini_portile2-2.4.0  test-unit-3.3.4
activestorage-6.0.2.2  minitest-5.13.0      thor-1.0.1
activesupport-6.0.2.2  net-telnet-0.2.0     thread_safe-0.3.6
builder-3.2.4          nio4r-2.5.2          tzinfo-1.2.7
bundler-2.1.4          nokogiri-1.10.9      websocket-driver-0.7.1
concurrent-ruby-1.1.6  power_assert-1.1.7   websocket-extensions-0.1.4
crass-1.0.6            racc-1.4.16          xmlrpc-0.3.0
erubi-1.9.0            rack-2.2.2           zeitwerk-2.3.0
globalid-0.4.2         rack-test-1.1.0




### cd /home/chris/.gem/ruby/2.7.0 ###

bash: cd: /home/chris/.gem/ruby/2.7.0: No such file or directory



### /home/linuxbrew/.linuxbrew/Cellar/ruby/2.7.1_3/lib/ruby/gems/2.7.0$ ls ###

cache  doc  gems  specifications



### /home/linuxbrew/.linuxbrew/Cellar/ruby/2.7.1_3/lib/ruby/gems/2.7.0/gems$ ls ###

bundler-2.1.2  minitest-5.13.0     racc-1.4.16  test-unit-3.3.4
bundler-2.1.4  net-telnet-0.2.0    rake-13.0.1  xmlrpc-0.3.0
irb-1.2.3      power_assert-1.1.7  rdoc-6.2.1
3
  • 1
    Did you run rbenv init?
    – max
    May 4, 2020 at 17:33
  • @max when I run it now: rbenv init >>> # Load rbenv automatically by appending # the following to ~/.bashrc: eval "$(rbenv init -)" <<< --- or did u mean during one step in the installation? (tried it now, rails still command not found)
    – Chris F
    May 4, 2020 at 17:34
  • Yeah you want to add eval "$(rbenv init -)" to .bashrc for it to happen automatically every time you start your shell. This is the hook that rbenv uses to hook into the shell and switch rubies. You also want to ensure rbenv in on your path. If that doesn't help use the script to troubleshoot your installlation: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash.
    – max
    May 4, 2020 at 17:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.