Terminal: command not found

Hi,


I was trying to install Sass on my computer, I started to go through this tutorial:

http://sass-lang.com/install

But it gave me an error: "ERROR:
Error installing sass: ERROR: Failed to build gem native extension."


So I did some googleing and it turned out that I need Ruby to install Sass, which should be preinstalled on Mac, so to check if it is, I tried to use this tutorial:

https://code.tutsplus.com/tutorials/how-to-install-ruby-on-a-mac--net-21664

It turned out that my version of Ruby is: "ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]"

So I thought why not update it, I typed: "

$ \curl -L https:
//get
.rvm.io |
bash
-s stable --rails --autolibs=enabled" but I got a "-bash: $: command not found" error.

As the tutorial suggested, I should have GIT installed, so I went here to install GIT:

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

As you might have guessed now, I got an error again:

"-bash: $: command not found"

And that's how I ended up here.

I tried this:

https://stackoverflow.com/questions/29688932/mac-terminal-bash-command-not-found #29689064

The 2nd answer from this:

terminal - "-bash: ls: command not found" - Ask Different


I don't really know what the code means, I just copy-pasting them, but nothing seemed to help so far, I got the same "command not found" error for anything I try to type in the terminal.


Anyone could help me walk through what to do? I just want Sass installed, it's quite frustrating to go through all of this.


Many thanks!

MacBook Air (13-inch, Early 2014), macOS High Sierra (10.13.1), null

Posted on Jan 29, 2018 2:16 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 29, 2018 6:11 AM

Several things. The most common problem is a broken PATH environment variable.


If you have one of these files, chances are it has a broken PATH assignement

.bash_profile

.bash_login

.profile

.bashrc

By default none of these file exist on your system, but are frequently created by heavy duty terminal users, or by terminal based program install scripts, or by web instructions to a user.


If you have one of the above files, you should examine it to see if it has a PATH assignment. If it does, you should either fix it, or you should rename the file so it is no longer looked at, and restart your terminal session.


Another cause might be scripts that have (CR)(LF) line terminators (ala Windows/DOS text files), or (CR) line terminators (ala old Mac OS Classic text files). Or worse, a word processor based file, being run as a script (I shutter to think about that 🙂). Unix based shell scripts must be (LF) terminated.


With bad line terminators in mind, it is critical that if you are doing the editing of a .bash_profile, or .bash_login, or .profile, or .bashrc file that you DO NOT use the wrong kind of editor. If you are using nano, pico, vi, vim, emacs, etc... they should all create the correct kind of file, where nano would be the simplest, and vi, vim, emacs the most difficult to use, unless you are an experienced user of those programming editors.


If you are using Applications -> TextEdit, make sure you have TextEdit -> Format -> Make Plain Text has been selected. Rich Text will not work as a shell initialization file.


Or download BBEdit (the demo ONLY which is FREE!), and use that. BBEdit will still be very functional AFTER the Demo period expires as a text editor. <https://www.barebones.com/products/bbedit>. You do not need to buy it to use it.

Similar questions

7 replies
Question marked as Top-ranking reply

Jan 29, 2018 6:11 AM in response to testimo

Several things. The most common problem is a broken PATH environment variable.


If you have one of these files, chances are it has a broken PATH assignement

.bash_profile

.bash_login

.profile

.bashrc

By default none of these file exist on your system, but are frequently created by heavy duty terminal users, or by terminal based program install scripts, or by web instructions to a user.


If you have one of the above files, you should examine it to see if it has a PATH assignment. If it does, you should either fix it, or you should rename the file so it is no longer looked at, and restart your terminal session.


Another cause might be scripts that have (CR)(LF) line terminators (ala Windows/DOS text files), or (CR) line terminators (ala old Mac OS Classic text files). Or worse, a word processor based file, being run as a script (I shutter to think about that 🙂). Unix based shell scripts must be (LF) terminated.


With bad line terminators in mind, it is critical that if you are doing the editing of a .bash_profile, or .bash_login, or .profile, or .bashrc file that you DO NOT use the wrong kind of editor. If you are using nano, pico, vi, vim, emacs, etc... they should all create the correct kind of file, where nano would be the simplest, and vi, vim, emacs the most difficult to use, unless you are an experienced user of those programming editors.


If you are using Applications -> TextEdit, make sure you have TextEdit -> Format -> Make Plain Text has been selected. Rich Text will not work as a shell initialization file.


Or download BBEdit (the demo ONLY which is FREE!), and use that. BBEdit will still be very functional AFTER the Demo period expires as a text editor. <https://www.barebones.com/products/bbedit>. You do not need to buy it to use it.

Jan 29, 2018 7:56 AM in response to testimo

Open a Terminal window. Assume for simplicity that your bash prompt is '$'. Type the command in blue text which will list the hidden Bash dot files. Follow Bob's advice and get BBEdit, and then use it to open the .bash_profile:


$ ls -a | grep "bash|profile"

# comment: as an example, open the hidden .bash_profile

$ open -a BBEdit ~/.bash_profile


What is more complicated is that the installation of the Ruby Version Manager (rvm) attempts to edit the PATH statement in every $HOME/.bashrc, $HOME/.bash_profile, $HOME/.profile, and $HOME/.zshrc file that it finds. It makes two changes, once before any ruby is installed, and then after a ruby version has been installed.


It wants the path to the installed Ruby gems to be the first item in your PATH. For Ruby v2.3.6, mine is:


export PATH="$HOME/.rvm/gems/ruby-2.3.6/bin:.:$HOME/bin:$PATH


and near the end of the .bash_profile, will be the following:


export PATH="$PATH:$HOME/.rvm/bin"


You won't be able to install any Ruby version until you have either an Xcode, or Command Line Tools for Xcode installed so that rvm can actually compile the downloaded Ruby source code. You cannot meet the RVM prerequisites until you have the homebrew package manager correctly installed.


You must be certain that you tell RVM to use the system Ruby, or its current installed Ruby via:


rvm use system

rvm use 2.3.6

Jan 29, 2018 9:15 AM in response to testimo

You need Apple compilation tools to compile the Ruby gems, and sudo privileges to update the System gem repository.


I have purposely left my System Ruby and its gems untouched, as some Apple applications or Library frameworks expect these to not be changed. Installing the compass/sass gem will introduce many other dependency installations, that may require specific Ruby version. Doing so, may have adverse effects on the System Ruby and its gem integrity.


This is specifically why I use a separate Ruby version and gem solution — to preserve the System Ruby.


Your PATH statement as you have shown, includes most items that are already included in the default PATH. It can be restated:


export PATH=$PATH:/usr/X11/bin

Jan 29, 2018 7:25 AM in response to BobHarris

Hi BobHarris,


Thanks for trying to help!

I'm not really used to using the terminal or editing system files, but I'm trying.

I tried to search for the files you mentioned with the terminal using:

sudo find / -name *.bashrc


I got this as a result:


find: /private/var/db/ConfigurationProfiles/Store: Operation not permitted

find: /private/var/folders/n8/qpz2rsd505z89fk1qb_853gm0000gn/0/SafariFamily: Operation not permitted

find: /private/var/folders/n8/qpz2rsd505z89fk1qb_853gm0000gn/0/com.apple.LaunchServic es.dv: Operation not permitted

find: /private/var/folders/n8/qpz2rsd505z89fk1qb_853gm0000gn/0/com.apple.nsurlsession d: Operation not permitted

find: /private/var/folders/n8/qpz2rsd505z89fk1qb_853gm0000gn/0/com.apple.routined: Operation not permitted

find: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/0/com.apple.nsurlsession d: Operation not permitted

find: /dev/fd/3: Not a directory

find: /dev/fd/4: Not a directory

Not sure what to do with them. I'm the only user on this computer.

using "sudo find -name .bash_login"

returns these:

find: illegal option -- n

usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]

find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]

Can you guide me how to find those files?

What if I don't have them?


Many thanks!

Jan 29, 2018 8:48 AM in response to VikingOSX

Hi VikingOSX,


Thanks for trying to help!

Not sure what you're saying, but I downloaded BBEdit and opened .bash_profile with it.

This is what's inside:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH


I don't really need to update Ruby, I just want to install Sass, but when I type sudo gem install sass into the console it gives me an error:

"

ERROR:
Error installing sass:

ERROR: Failed to build gem native extension.


current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180129-33788-1qk5wva.rb extconf.rb

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/rub y.h


extconf failed, exit code 1


Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18 for inspection.

Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/ffi-1.9.18/gem_ma ke.out"

Do you know how to solve this?

I feel I got too far from my original problem.

Jan 29, 2018 11:05 AM in response to testimo

As VikingOSX is more knowledgable about Ruby and things, I'll just through this out. Think of it as a tangent.


Shell initialization files are found in your home directory, so I should have said

$HOME/.bash_profile

$HOME/.bash_login

$HOME/.profile

$HOME/.bashrc

Which makes it much easier to find them, vs using the 'find' command starting at the / (root) directory 🙂


And again, by default none of those files exist unless explicitly created by the user or an install script, so if someone else reading this thread cannot find any of them, it is OK.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal: command not found

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.