YAML safe loading is not available - npm

When I want to install compass with gem install compass, I occurred with this error:
YAML safe loading is not available.
Please upgrade psych to a version that supports safe loading (>= 2.0).
what The cause of this error and how can I solve the problem?

It sounds like the psych gem needs to be updated. Try running gem install psych and then gem update psych.
Suggested by looking at the psych readme file here: https://github.com/ruby/psych/blob/master/README.md
EDIT: you might also have to update your version of ruby. This depends on how you have installed ruby, but #ewerx has one suggestion in their answer.

To resolve this I first upgraded Ruby from 2.0.x to 2.4.2 (https://gorails.com/setup/osx/10.12-sierra):
rbenv install 2.4.2;
rbenv global 2.4.2
Then updated gems:
sudo gem update --system;
gem update
It may be sufficient to just update gems.

The following part of the post on https://gorails.com/setup/osx/10.12-sierra solved my issue.
We will be setting up a Ruby on Rails development environment on macOS 10.12 Sierra.
Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.
Installing Homebrew
First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source.
Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes.
Open Terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
Choose the version of Ruby you want to install:
Now that we have Homebrew installed, we can use it to install Ruby.
We're going to use rbenv to install and manage our Ruby versions.
To do this, run the following commands in your Terminal:
brew install rbenv ruby-build
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Install Ruby
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v

Related

Deploy Rails 3 with Phusion Passenger on Ubuntu WITH ALL GEMS INCLUDED

I need to deploy a Rails 3/Phusion Passenger/Apache2 app to an Ubuntu 12.04 server without installing ANY gems on the server.
I can install any Debian packages.
How can I include all needed gems (including Rails, a couple of gems installed from git projects on github, and a bunch of regular gems installed from rubygems.org) inside my project so that, after deployment, Passenger will find Rails and all the gems and be happy?
(I know many people will probably be curious WHY I would want to do this. I can't talk about that, unfortunately. Sorry.)
Here are some things that have not worked. One of them might work if revised a little, I don't know:
Failed method 1:
On Ubuntu 12.04 dev machine. Ruby 1.9.3. Bundler 1.3.5. bundle package --all. Git commit.
On Ubuntu 12.04 server machine (gem installation from Internet not possible). Deploy project files and install packages (apache2, ruby1.9.3, ruby-bundler, rubygems, libapache2-mod-passenger which brings ruby1.8 with it). bundle -v gives Bundler version 1.0.15 (from ruby-bundler package). Make sure .bundle/config file from dev machine is also deployed. bundle install --local tries to download git gems from github, so fail.
Try using bundle package --all, which should save your gems into ./vendor/cache. You could also unpack the gems on your local environment with gem unpack --target vendor to save them in the vendor directory. Then you can give a location in the Gemfile so that your application can find the gems. Can you just not use the network to install gems, or are you really not allowed to install gems in any way?
Sources:
1,
2
Try using the pkgr tool, which can convert your Rails app and all dependencies into a single installable Debian package.
Download the bundler 1.3.5 gem from http://rubygems.org/downloads/bundler-1.3.5.gem and put it in vendor/
In an Ubuntu 12.04 vm, do bundle package --all. Git commit and push.
Clone on the Ubuntu server.
apt-get install each of apache2, ruby1.9.3, etc. (not rubygems or ruby-bundler. Both provide an old version of Rubygems and Bundler. A newer version of rubygems is included in the ruby1.9.3 package.)
Follow ALL of the instructions in section 2.3 at http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu
Make sure you have the right Ruby and Rubygems versions set to the ruby and gem commands:
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.3 200
update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.3 200
(Phusion Passenger doesn't care about this, but it's probably a good idea for the gems we are about to install and for debugging stuff with the Rails console or whatever in the future.)
gem install --local vendor/bundler-1.3.5.gem
bundle install --local
Set up all your other Apache config...
service apache2 restart

How do I install same version of ruby as different names with rvm?

After I installed a version of ruby with rvm, I noticed that some minor configuration issue on installation process. So I wanted to try to install with another configuration options, but I don't want to spoil the installed ruby at all.
So I just to attempt to backup the installed ruby before rvm reinstall.
(cd .rvm/rubies && mv ruby-1.9.3-p194 ruby-1.9.3-p194.org)
In my case, reinstallation fixed the issue, I didn't rollback ruby. So, I don't know this can work.
Are there any clean or correct way? Just for future references.
you can install named rubies:
rvm install 1.9.3-test1 [options]
and after it worked set it as default:
rvm use 1.9.3-test1 --default
or reinstall the original 1.9.3, named rubies are useful especially for testing compilation flags or patched rubies:
rvm install 1.9.3-performance --patch falcon
You can also have different gemsets with the same version using
rvm create gemset projectname

Installing newer version but still older version active

I needed some features from a newer version so I installed 1.9.3 . However after the installation when I write "ruby --version" it still gives me back 1.8.7.
Any idea how to update it?
I used rvm install ruby-1.9.3-p0 to install it, and this worked on other machines, just not on this one
there is a shortcut for your needs:
rvm use 1.9.3-p0 --install --default
where:
--install will install this ruby if it is not yet installed
--default will set this ruby default so it will be loaded when you open new shell

can't get "rails console" to work on ubuntu 11.10

I want to use rails console and I'm using ubuntun 11.10 currently I have found the issue
error is something :
completion.rb:9:in `require': no such file to load -- readline (LoadError)
and I found a way to solve it:
http://blog.jasonmeridth.com/2010/11/25/readline-error-with-rvm-and-rails-3.html
but seems in ubuntu 11.10 the libreadline5-dev is missed and it is replaced with version 6
I installed version 6 and also I get the version 5 from
https://launchpad.net/ubuntu/oneiric/i386/libreadline-gplv2-dev/5.2-9ubuntu1
but yet if I try to run following code :
ruby extconf.rb
I'll get following lines :
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
the "no"s part is my problem , so how can I solve this problem?
Ubuntu 11.10 uses newer readline library which not in sync with the readline package offered by rvm
To solve this (assuming you use single-user installation of rvm) do:
1) ensure you have installed ubuntus readline and editline dev packages
sudo apt-get install libreadline6 libreadline6-dev
2) configure ruby's readline extension to use the systems libs, not rvm's packages
rvm pkg uninstall readline
cd ~/.rvm/src/ruby-1.9.2-p290/ext/readline
ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
make install
3) go to your project and start up the rails console
Tip: You can call
rvm requirements
to see what ubuntu packages should be installed to use rvm ruby
You have to install the readline development packages before compiling ruby. Just run
sudo apt-get install libreadline6-dev
Alternative (as suggested in the article you linked) you can use RVM to get the appropriate readline sources by running
rvm package install readline
Edit: Once you've installed the readline packages from source, you can install your rubies like this
rvm install 1.9.3 --with-readline-dir="$rvm_path/usr"
If you alredy have installd a specific ruby, just use reinstall instead on install.

Ubuntu 11.04 Ruby on Rails install write permissions error

I am trying to install rails and have installed rvm and am trying to install rails but it is saying I do not have write permissions.
$ gem install rails --version 3.0.7
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.8 directory.
When I try sudo it give me this error, I know that you can use --no-ri --no-r-doc but even when I did this rails was not installed properly. Does anyone have any ideas?
$ sudo gem install rails --version 3.0.7
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
file 'lib' not found
Installing RDoc documentation for rails-3.0.7...
file 'lib' not found
from my experience with rvm, gems should't stay in /var/lib/
if you didn't specifically asked for this, there might be a problem with your rvm installation
if so, i would definetly recommend a clean rvm install by following ryan bigg's guide of installing rvm. i followed it every time and never ever had the slightest problem after.
hope this helps!