Could not find 'sass' among total gems - ruby

I have previously been running an old version of Ruby, version 1.9.3, because that is what Ubuntu apt-get installs. Sass was installed with gem install sass and things works as planned. However, Sass would always tell me "Please upgrade ruby. < 2.0.0 will soon be not-supported," so I wanted to do that. I ran sudo apt-get purge ruby rubygems libruby and started to go to work.
First, I tried to install is with rvm, and that didn't go too well, so I did my best to remove that, but I may have missed some things, so don't rule that out. As per this guide ruby seems to have been successfully installed. I then ran gem install sass so I can compile some css. The following are some relevant outputs to prove the correct installation:
$ chruby
ruby-2.1.9
* ruby-2.3.1
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
$ sass -v
Sass 3.4.22 (Selective Steve)
However, when I try to integrate Sass compiling into NetBeans 8.1, the compiler throws this error for every file.
"~/.gem/ruby/2.3.1/bin/sass" "--cache-location" "~/.cache/netbeans/8.1/sass-compiler" "--debug-info" <sass input> <sass output>
~/.rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'sass' (>= 0.a) among 11 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=~/.gem/ruby/2.3.0:~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0', execute `gem env` for more information
from ~/.rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from ~/.rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from ~/.gem/ruby/2.3.1/bin/sass:22:in `<main>'
Every file comes up with this error.
From reading around, it seems like it might be a path error. But it looks like I have the correct path setup.
$ echo $PATH
~/.gem/ruby/2.3.1/bin:~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/bin:~/.rubies/ruby-2.3.1/bin:~/bin:~/.gem/ruby/2.3.1/bin:~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/bin:~/.rubies/ruby-2.3.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ echo $GEM_PATH
~/.gem/ruby/2.3.1:~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0
I'm willing to try anything at this point.
EDIT: More information on why it might be a path error.
whereis for ruby, gem, and sass all output nothing. dpkg --get-selections | grep ruby outputs nothing. type ruby outputs the path to the .rubies directory, along with type gem and type sass outputs to the .gem directory.

RVM installation instructions
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
source /home/rvm/.rvm/scripts/rvm
rvm install <the ruby version you want e.g. 2.3.1>

Related

Installed Ruby gems appear to exist on disk, but can't be found when run or referenced by other gems

I'm trying to install Ruby on Rails on my openSUSE Tumbleweed machine and running into some problems.
First, I installed rvm:
curl -L get.rvm.io | bash -s stable
Then I used it to install Ruby 2.3.1:
rvm install 2.3.1
rvm use 2.3.1 --default
Then I configured gem to install to my home directory, not /:
$ cat ~/.gemrc
gem: --user-install
Then I used gem to install bundler:
gem install bundler
That's where I ran into problems. The installation seemed to complete fine:
$ gem install bundler
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Done installing documentation for bundler after 3 seconds
1 gem installed
and I can see it on disk:
$ which bundler
/home/<me>/.gem/ruby/2.3.0/bin/bundler
$ > ls ~/.gem/ruby/2.3.0/gems/bundler-1.14.6/
bin CODE_OF_CONDUCT.md exe LICENSE.md README.md
bundler.gemspec CONTRIBUTING.md ISSUES.md man
CHANGELOG.md DEVELOPMENT.md lib Rakefile
But it doesn't actually run, giving a really weird error message:
$ bundler -v
/home/<me>/.rvm/rubies/ruby-2.3.1/lib64/ruby/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
from /home/<me>/.rvm/rubies/ruby-2.3.1/lib64/ruby/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /home/<me>/.gem/ruby/2.3.0/bin/bundler:22:in `<main>'
And sure enough, gem list doesn't see it:
$ gem list | grep -i bundler | wc -l
0
I get a similar problem when trying to run rails; it complains that it can't find railties, even though it is clearly installed on disk in ~/.gem/ruby/2.3.0/gems, and gem list doesn't show it.
What's going on here?
First select rvm source by command:
source ~/.rvm/scripts/rvm
and then try.

'sudo ruby setup.rb' won't install Gems on Vagrant box

I'm new to using Vagrant and am trying to install Gems on it (Ruby is already installed). I am following the instructions here.
I've downloaded the latest version of Gems and extracted it. I have "cd'd" into that folder and have tried to run:
ruby setup.rb
But get a Permission denied error, so I try sudo:
sudo ruby setup.rb
But this gives me the error:
sudo: ruby: command not found
Would anyone know what's going on here?
Edit - more info
I checked the version of ruby and its 2.3.0p0.
If I try to check the version of Gems is says to install Ruby 1.9.1.
I don't really understand this...
sudo doesn't preserve your $PATH environment variable, so unless ruby is installed somewhere that's in root's path, it's not going to be found.
Run which ruby to find out where ruby is installed, then sudo /path/to/ruby setup.rb
Also, more importantly, that's completely unnecessary. Those instructions are old. Rubygems has been built-in to ruby for a long time now. The site you linked even says, "If you’re on Ruby 1.9.*, then you don’t have to worry about installing Rubygems; it’s built in." If you're on 2.3.0, you don't need to install Rubygems, you have it already.
I suggest to you use RMV to install Ruby and Gem versions.
Install RVM
https://rvm.io/
- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
- \curl -sSL https://get.rvm.io | bash -s stable
- source /home/vagrant/.rvm/scripts/rvm
Install Ruby
rvm get stable --autolibs=enable
rvm install ruby-2.3.1
Use default ruby version
rvm --default use ruby-2.3.1

How to set up Jekyll cleanly on an existing OSX system?

I am an inexperienced Ruby user and I want to start using a Jekyll theme. I am working on OSX El Capitan and there may be old Ruby tools lying around on this machine.
I have downloaded this theme and installed it to a local directory. Next I tried to run bundle and saw this error:
An error occurred while installing nokogiri (1.5.9), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.
Full error output here: http://pastebin.com/mv2r91xU
Next, I tried running gem install nokogiri -v '1.5.9', but I saw this error:
-bash: /usr/local/bin/gem: No such file or directory
I don't know how to install gem, and I suspect I'm not using the "right" Ruby or bundler. Where should these tools be? What do I need to check I've deleted to start cleanly from scratch? (e.g. I tried setting up rbenv, but I think it may have failed because I already had RVM installed)
These are the paths to ruby and bundler:
$ which ruby
/usr/bin/ruby
$ which bundle
/usr/local/bin/bundle
I'd suggest using rbenv to manage your Ruby versions, and ignoring the default system-wide version. You mention you tried, but I think it'd be worth giving it another go.
rbenv is best installed through Homebrew, install it with the following:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install rbenv with Homebrew:
$ brew install rbenv ruby-build
You can then set and switch between Ruby versions (giving you clean environments) anytime without changing the default system version:
$ rbenv install 2.3.1
$ rbenv global 2.3.1
$ ruby -v
Once Ruby is sorted, you should be able to install and run the latest Jekyll through the Bundler:
$ gem install jekyll
$ jekyll new my-awesome-site
$ cd my-awesome-site
$ bundle install
$ bundle exec jekyll serve
Running Jekyll through Bundler rather than directly is the new suggested method.

Why do I get "ERROR: While executing gem ... (Gem::FilePermissionError)"?

I uninstalled RVM and re-installed using a single user installation using:
\curl -L https://get.rvm.io | bash -s stable
When I do bundle, it prompts for:
Enter your password to install the bundled RubyGems to your system:
I tried using the answer in "ERROR: While executing gem … (Gem::FilePermissionError)" which did not fix it.
Then, while trying to install the gem manually, I got:
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
then running gem install nokogiri -v '1.6.0' returned:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
I checked all the similar posts on SO, but they didn't solve the problem. What am I missing?
I spent a lot of time fixing this issue on my MacBook. The gem update --system does not work for me.
At last, putting the following code in the ~/.zshrc file and create a new zsh session works for me.
export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"
after you install RVM you still need few more steps:
Load RVM to the current shell:
source ~/.rvm/scripts/rvm
Usually this would not be needed if you close and open your terminal again
Install ruby:
rvm install ruby
Use ruby:
rvm use ruby
The last step is very important as your error message mentioned system ruby not the one controlled by RVM.
Make sure to update your system rubygems with this command : sudo gem update --system --no-user-install.
bundler use it instead your local version and your bundler version could be incompatible with your system rubygems.
It works for me ;)

Installed fxruby over macports, now rubygems is broken

I installed fxruby using
$sudo port install rb-fxruby
As suggested in the book.
It works, my hello world program worked correctly.
Now, though, other code that I have written is broken, whenever I try to use any code that relies on a gem, it does not work. When I do
$ruby -e "require 'rubygems'"
in my code, it gives
"LoadError: no such file to load — rubygems"
When I set my RUBYOPT="rubygems" in my .bash_profile
$ruby -e "puts 'hello world'"
ruby: no such file to load -- ubygems (LoadError)
(it says 'ubygems' without the 'r' on the front, not sure why)
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00351.html suggests I check my gem location against my ruby location, I get:
$cat `which gem` | head -n 1
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
$ls -l `which ruby`
-rwxr-xr-x 2 root admin 12680 Feb 7 03:40 /opt/local/bin/ruby
I assume this means that the gems are confused, but not sure how to remedy it. Any ideas? It sucks not having gems.
---UPDATE---
Forgot to list versions:
$which gem
/usr/bin/gem
$gem --version
1.3.5
$ruby --version
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9]
If you installed rb-fxruby via macport it will install the macport ruby as well.
$ port info rb-fxruby
...
Library Dependencies: ruby, fox, fxscintilla
...
But as you can see rb-rubygems (the macport version of rubygems) is not listed as a dependency, so you will have to install it manually.
$ sudo port install rb-rubygems
should do it for you.
It looks like you are trying to use the Apple-supplied gem that works with the Apple-supplied ruby. Did you install the MacPorts version?
sudo port install rb-rubygems
/opt/local/bin/gem

Resources