3

When trying to execute sass --watch scss:css inside of a target folder I get returned the message command not found

I know I had sass installed. gem list doesn't show that it's installed anymore.

I run sudo gem install sass and get the following message:

WARNING: You don't have /root/.gem/ruby/2.3.0/bin in your PATH
         gem executables will not run.

I go to my .bashrc file. I have PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"

I also put it in /etc/bash.bashrc just in case. Nothing Changes.

I go to /etc/profile and insert:

#Setting the GEM_PATH and GEM_HOME variables may not be necessary, check 'gem env' output to verify whether both variables already exist 
 GEM_HOME=$(ls -t -U | ruby -e 'puts Gem.user_dir')
 GEM_PATH=$GEM_HOME
 export PATH=$PATH:$GEM_HOME/bin

I reload profile with . /etc/profile

I try reinstalling sass with sudo gem install sass

Still the same error message. gem list still doesn't show sass

What now??

7
  • Did you add the PATH directory to root's bashrc or to that of a non-privileged user? Feb 15, 2016 at 17:27
  • I indeed did not have a .bashrc inside /root/ I copied the file from /home/USER and retried the install. Same error message.
    – Andrew
    Feb 15, 2016 at 18:07
  • sorry, but I do not understand whether you are trying to execute the command as toor or as an unprivileged user. Feb 15, 2016 at 18:14
  • I entered the directory path manually into /root/.bashrc and it works now. Although that's probably not the ideal solution. How can I edit ruby Gem.user_dir ?
    – Andrew
    Feb 15, 2016 at 18:15
  • I'm running gem as a superuser
    – Andrew
    Feb 15, 2016 at 18:17

2 Answers 2

3

By default in Arch Linux, when running gem, gems are installed per-user (into ~/.gem/ruby/), instead of system-wide (into /usr/lib/ruby/gems/).

This is considered the best way to manage gems on Arch, because otherwise they might interfere with gems installed by Pacman.

Gems can be installed system wide by running the gem command as root, appended with the --no-user-install flag. This flag can be set as default by replacing --user-install by --no-user-install in /etc/gemrc (system-wide) or ~/.gemrc (per-user, overrides system-wide).

Type in your terminal

sudo gem install sass --no-user-install

See the arch wiki about ruby gems. Read Installing gems per-user or system-wide

5

You are trying to install the gem using sudo, but the system knows the path for your user but not for the sudo user.

To solve this, Add the following line to your ~/.bashrc or .~/zshrc file:

PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"

Use the source command to update your profile file or reopen your terminal.

If you use zsh:

source ~/.zshrc

or with bash

source ~/.bashrc

In this way, you will install your gems without sudo, like this example:

gem install rspec 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .