Install Colorls on macOS and zsh - ruby

I want to install Colorls. I am completely new to Ruby. To install Colorls I executed:
gem install colorls --user-install
After I while (maybe after I installed Anaconda) Colorls is not working anymore.
zsh: command not found: colorls
Here's some info:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.2
- RUBY VERSION: 2.6.1 (2019-01-30 patchlevel 33) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/matteo/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin
- SPEC CACHE DIRECTORY: /Users/matteo/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.6.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.6.0
- /Users/matteo/.gem/ruby/2.6.0
- /usr/local/Cellar/ruby/2.6.1/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/Cellar/ruby/2.6.1/lib/ruby/gems/2.6.0
- /Users/matteo/.gem/ruby/2.6.0
- /usr/local/lib/ruby/gems/2.6.0
- /usr/local/lib/ruby/gems/2.6.0
- /usr/local/opt/ruby/bin
- /Users/matteo/bin
- /usr/local/bin
- /sbin
- /usr/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin

I always forget how to install colorls when I reformat my Mac.
I have:
macOS Catalina Version 10.15.7 (don't miss with the preinstalled ruby)
I follow these steps:
Step -1-
Install ruby using homebrew
brew install ruby
Step -2-
Go to the directory
cd /usr/local/Celler/ruby/<x.x.x>/bin
# Or for ARM Mac I use here 3.1.1 that comes with brew install ruby
cd /opt/homebrew/Cellar/ruby/3.1.1/bin
# Then
./gem install colorls
my version is (3.0.1)
Step -3-
Now you are ready to link this library to the default one you installed before (following the GitHub repo steps of the colorls)
ln -s /usr/local/lib/ruby/gems/x.x.x/bin/colorls /usr/local/bin/colorls
# or for ARM Mac I use here gem 3.1.0
ln -s /opt/homebrew/lib/ruby/gems/3.1.0/bin/colorls /usr/local/bin/colorls
Hint: if you find any other colorls in the directory prior to executing the link command just remove it.
now check:

Is it possible your ruby version doesn't match gem version? Seems like minor version in
/usr/local/Cellar/ruby/2.6.1/lib/ruby/gems/2.6.0
Make sure you still have the gem installed:
which colorls
#should output something like: /Users/yourusername/.rvm/gems/ruby-2.6.0/bin/colorls
See if the gem is indeed installed
gem list colorls
Then maybe try reinstall see https://github.com/athityakumar/colorls#install
You might wanna use a version manager, I recommend RVM see https://rvm.io/rvm/install

Related

Find where a specific Ruby version is installed

On Mac, I used to have rbenv as Ruby version manager but recently switched to asdf. I want to create a Ruby on Rails 7.0.4 but it uses an outdated version and I'd like to locate it.
$ rails new app
"Rails 7 requires Ruby 2.7.0 or newer.
You're running
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin"
$ which ruby
/Users/kawsay/.asdf/shims/ruby
$ ruby -v
ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [arm64-darwin21]
$ irb
irb(main):001:0> RUBY_VERSION
=> "3.0.5"
$ asdf list ruby
2.7.4
*3.0.5
$ brew info ruby
==> ruby: stable 3.2.0 (bottled), HEAD [keg-only]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.33
- RUBY VERSION: 3.0.5 (2022-11-24 patchlevel 211) [arm64-darwin21]
- INSTALLATION DIRECTORY: /Users/kawsay/.gem
- USER INSTALLATION DIRECTORY: /Users/kawsay/.gem/ruby/3.0.0
- RUBY EXECUTABLE: /Users/kawsay/.asdf/installs/ruby/3.0.5/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/kawsay/.gem/bin
- SPEC CACHE DIRECTORY: /Users/kawsay/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/kawsay/.asdf/installs/ruby/3.0.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- arm64-darwin-21
- GEM PATHS:
- /Users/kawsay/.gem
- /Users/kawsay/.gem/ruby/3.0.0
- /Users/kawsay/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/kawsay/.asdf/installs/ruby/3.0.5/bin
- /Users/kawsay/.asdf/shims
- /opt/homebrew/opt/asdf/libexec/bin
- /Users/kawsay/.cargo/bin
- /opt/homebrew/opt/openssl#2.8/bin
- /opt/homebrew/opt/python#3.8/bin/python3
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
$ which rbenv
rbenv not found
$ which rvm
rbenv not found
How can I find where ruby 2.6.8p205 is installed ?
You have an issue where you have system Ruby, brew Ruby, asdf Ruby, and rbenv Ruby. In short, your system is confused about where to find things.
The first step is to remove brew's Ruby installation:
brew uninstall ruby
The second step is to remove rbenv completely. (or use the official docs)
The third step is to make sure that system Ruby does not have the Rails gem installed. Start a shell without loading your profile so that you can bypass asdf and any other configuration:
env -i bash --norc --noprofile
Then confirm it's pointing at system Ruby: (your version will differ slightly depending on your version of macOS)
$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
Then uninstall the Rails gem:
gem uninstall rails
But while you're at it you might want to remove all the gems you installed using system Ruby: (ignore any errors here)
gem uninstall -aIx
Now close that shell session and switch back to your default shell. Make sure that your shell profile is cleared of anything related to rbenv and that you have no GEM_* environment variables being set. (assuming you use ZSH, check every ~/.zsh* file and ~/.gemrc) Then start a new shell session to load the cleaned profiles.
Then make sure asdf has a properly groomed environment:
asdf reshim
Now when you run gem env you should see output like this:
RubyGems Environment:
- RUBYGEMS VERSION: 3.4.1
- RUBY VERSION: 3.2.0 (2022-12-25 patchlevel 0) [arm64-darwin22]
- INSTALLATION DIRECTORY: /Users/foo/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0
- USER INSTALLATION DIRECTORY: /Users/foo/.gem/ruby/3.2.0
- RUBY EXECUTABLE: /Users/foo/.asdf/installs/ruby/3.2.0/bin/ruby
- GIT EXECUTABLE: /opt/homebrew/bin/git
- EXECUTABLE DIRECTORY: /Users/foo/.asdf/installs/ruby/3.2.0/bin
- SPEC CACHE DIRECTORY: /Users/foo/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/foo/.asdf/installs/ruby/3.2.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- arm64-darwin-22
- GEM PATHS:
- /Users/foo/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0
- /Users/foo/.gem/ruby/3.2.0
Note the difference between INSTALLATION DIRECTORY and EXECUTABLE DIRECTORY in this output and yours. You need to have output that looks like this, otherwise that means that asdf is not installed properly and you should restart the installation of asdf from the beginning.
Afterwards, re-run gem install rails and you should be able to complete rails new app successfully.
If not, there is a shortcut to run commands with asdf for any given command:
asdf exec gem install rails
asdf exec rails new app
asdf exec rails server
This should bypass everything else and use asdf exclusively.

How do I reset Ruby and RubyGems / Path Variable? I have installed multiple versions while trying to fix and issue with Jekyll and Bundler

I am running macOS Catalina 10.15.3 and cannot execute Jekyll commands. I suspect it's the result of too many versions of Ruby / RubyGems installed and the conflicting paths I have created haphazardly, I'm pretty sure my path variable is completely messed up:
echo $PATH returns
/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:export
Here are the jekyll-related issues:
I receive -bash: jekyll: command not found when trying jekyll serve and when running bundle exec jekyll serve it returns Could not locate Gemfile or .bundle/ directory.
I think another issue compounding this is that I installed jekyll globally when trying to update it. I notice that it pops up with all of its dependancies when running gem list
For reference - check out what I get when I run gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x86_64-darwin19]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/will/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/will/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-19
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/will/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.0/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
- /usr/local/opt/ruby/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- export
Please help me get my system back to square one. I'm way in over my head and just want a do over.
My recommendation is to clear all those ruby paths from your PATH, remove every version of Ruby that you have installed and begin again with https://github.com/rbenv/rbenv
Install whatever versions of Ruby you need, and then use bundler to manage your gems https://jekyllrb.com/tutorials/using-jekyll-with-bundler/
Invoke jekyll using bundle exec jekyll and you should be back in business.

Can't seem to run ruby 2.6.0 homebrew version - always references back to system ruby 2.3.0

This is the situation: I am running mac OS Mojave 10.14.3 - It seems system is running ruby v2.3.0 and installed homebrew ruby 2.6.x when I try to run sass I get the following error:
> Sass is watching for changes. Press Ctrl-C to stop.
Gem::MissingSpecError: Could not find 'ffi' (>= 0.5.0, < 2) among 20 total gem(s)
Checked in 'GEM_PATH=/Users/samuellarcher/.gem/ruby/2.3.0:/Library/Ruby/Gems/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0', execute `gem env` for more information
Running gem env returns:
> RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.2 (2019-03-13 patchlevel 47) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/samuellarcher/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin
- SPEC CACHE DIRECTORY: /Users/samuellarcher/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.6.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.6.0
- /Users/samuellarcher/.gem/ruby/2.6.0
- /usr/local/Cellar/ruby/2.6.2/lib/ruby/gems/2.6.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/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Now, when i do a:
whereis ruby
it returns:
/usr/bin/ruby
and
echo $PATH
returns
/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
on top of that, the path priority under /private/etc/paths is set to:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
which seems correct to me. The .bash_profile file contains:
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
Checking gem directories:
ls /usr/local/lib/ruby/gems/2.6.0/gems/
returns
ffi-1.10.0 rb-fsevent-0.10.3 rb-inotify-0.10.0 sass-3.7.3 sass-listen-4.0.0 test-unit-3.3.0
with the missing ffi gem we are after.
ls .gem/ruby/2.3.0/cache/
returns
CFPropertyList-3.0.0.gem faraday-cookie_jar-0.0.6.gem mini_magick-4.5.1.gem simctl-1.6.5.gem
addressable-2.6.0.gem faraday_middleware-0.13.1.gem multi_json-1.13.1.gem slack-notifier-2.3.2.gem
atomos-0.1.3.gem fastimage-2.1.5.gem multi_xml-0.6.0.gem terminal-notifier-1.8.0.gem
babosa-1.0.2.gem fastlane-2.117.1.gem multipart-post-2.0.0.gem terminal-table-1.8.0.gem
bundler-2.0.1.gem gh_inspector-1.1.3.gem nanaimo-0.2.6.gem tty-cursor-0.6.1.gem
claide-1.0.2.gem google-api-client-0.23.9.gem naturally-2.2.0.gem tty-screen-0.6.5.gem
colored-1.2.gem google-cloud-core-1.3.0.gem os-1.0.0.gem tty-spinner-0.9.0.gem
colored2-3.1.2.gem google-cloud-env-1.0.5.gem plist-3.5.0.gem uber-0.1.0.gem
commander-fastlane-4.4.6.gem google-cloud-storage-1.16.0.gem public_suffix-2.0.5.gem unf-0.1.4.gem
declarative-0.0.10.gem googleauth-0.6.7.gem representable-3.0.4.gem unf_ext-0.0.7.5.gem
declarative-option-0.1.0.gem highline-1.7.10.gem retriable-3.1.2.gem unicode-display_width-1.5.0.gem
digest-crc-0.4.1.gem http-cookie-1.0.3.gem rouge-2.0.7.gem word_wrap-1.0.0.gem
domain_name-0.5.20180417.gem httpclient-2.8.3.gem rubygems-update-3.0.2.gem xcode-install-2.3.0.gem
dotenv-2.7.1.gem jwt-2.1.0.gem rubygems-update-3.0.3.gem xcodeproj-1.8.1.gem
emoji_regex-1.0.1.gem memoist-0.16.0.gem rubyzip-1.2.2.gem xcpretty-0.3.0.gem
excon-0.62.0.gem mime-types-3.2.2.gem security-0.1.3.gem xcpretty-travis-formatter-1.0.0.gem
faraday-0.15.4.gem mime-types-data-3.2018.0812.gem signet-0.11.0.gem
without the missing ffi gem
I might miss something fundemental but ideally I would like the homebrew ruby version 2.6.x running when I run sass - so where from here?
As per M. Zinovski's suggestion I uninstalled homebrew ruby and installed rbenv via homebrew. I followed instructions added
eval "$(rbenv init -)"
to .bash_profile - check installation seems fine.
SamuelserBook15:~ samuellarcher$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20190314)
Counting installed Ruby versions: 2 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
Local and global version set to newly installed rbenv 2.6.2
samuellarcher$ rbenv version
2.6.2 (set by /Users/samuellarcher/.ruby-version)
samuellarcher$ ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
However - when I ran sass - same old error - still referencing to 2.3.0 and ffi gem missing. So... absolutely min-bobbeling .. 2.6.2 is running why is it still pointing to 2.3.0 gem files???

Rubygems command not found

Centos 7
I have installed ruby 2.1.2 and rubygems but when I run rubygems --version I get the error rubygems: command not found.
My $PATH is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/lib/ruby/gems/2.1.0:/root/.gem/ruby/2.1.0
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.1.0
- USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.1.0
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.1.0
- /root/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /sbin
- /bin
- /usr/sbin
- /usr/bin
- /root/bin
- /root/ruby-2.1.2
- /usr/bin/gem
yum list installed shows rubygems.noarch
What do I need to do to get rubygems working?
To install ruby and rubygems on centOS, Run on Terminal
sudo yum install ruby
sudo yum install rubygems
To check version of of ruby and rubygems, Run
ruby -v
gem -v
Note: gem --version is same as gem -v
Update the gems list using :
sudo gem update
sudo gem update --system
Now, you can install any gem, using command
gem install <gem_name>
For instance, To install rails on centOS, Run
sudo gem install rails

gem command silently does nothing

I need to use Twitter's twurl command. In so doing I have installed Ruby and then Gem under Linux.
I've downloaded the latest version of twurl but when I attempt to use it to do an install it silently does nothing. I've also tried installing the oauth gem, but the same result. Gem must work because I can do a build using the gemspec file and it creates a gem file.
cam:~/twurl-master$ sudo gem build twurl.gemspec
sh: git: command not found
/usr/local/lib/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:55: command not found: git ls-files
sh: git: command not found
WARNING: description and summary are identical
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: twurl
Version: 0.9.2
File: twurl-0.9.2.gem
cam:~/twurl-master$ ls
COPYING Gemfile INSTALL README Rakefile bin lib test twurl-0.9.2.gem twurl.gemspec
cam:~/twurl-master$ sudo gem install twurl
cam:~/twurl-master$ sudo gem install twurl --remote
cam:~/twurl-master$ sudo gem list t
*** LOCAL GEMS ***
cam:~/twurl-master$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /home/cam/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/cam/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/X11R6/bin
cam:~/twurl-master$
I am at a loss as to know what to do. I've searched on Google but nobody else seems to have this particular problem. No error message is highly unhelpful...
I'm not sure what is the issue and if that's related, but just in case, twurl gem also requires the gem oauth-0.4.7.

Resources