Ubuntu 11.04 Ruby on Rails install write permissions error - ruby-on-rails-3

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!

Related

YAML safe loading is not available

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

RVM doesn't recognize installed gem, so bundle install fails

Bundle install command fails because gem install pg fails:
Make sure that `gem install pg -v '0.17.1'` succeeds
I can though, install pg with certain options:
gem install pg -- --with-pg-include=/usr/pgsql-9.3/include --with-pg-dir=/usr/pgsql-9.3
Still.. running bundle install fails, saying:
Make sure that `gem install pg -v '0.17.1'` succeeds
Well ye I know it fails, that why I installed it before, with options given,
How do I make the bundle see it the gem is already installed.? (or maybe make the bundle command to run gem install pg -- --with-pg-include instead of gem install pg -v '0.17.1' so it will succeed)
I also use rvm, and i'm rather clueless about it, so maybe even though I the pg gem is installed:
gem list pg
*** LOCAL GEMS ***
pg (0.17.1)
The application doesn't recognized the installed pg gem? if so How do I make the application's rvm see that the required gem is already installed?
Thank you
Finally found answer: How can I pass a parameter for gem installation when I run bundle install?
So in my case:
bundle config build.pg --with-pg-include=/usr/pgsql-9.3/include --with-pg-dir=/usr/pgsql-9.3
bundle install
And that took a day, well could have been worse
So you know in the future, this wasn't an RVM issue. This was a bundler and gem command parameter passing issue. RVM wasn't involved at that stage.

Rails Server Won't Run on OS X Lion

I'm a beginner programmer and I'm trying to get the rails server to run on OS X Lion. When I type "rails server" into the command line, I get this error:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
from /usr/bin/rails:18
What do you think a solution to the problem is? Any help you can provide would be greatly appreciated. Thanks!
You need to install the rails gem. You could probably do this by running bundle install inside that project.
Have you installed the Rails Gem?
gem install rails
Then do a gem list to see if Rails is in there.
It's also important that you be in the proper directory. So if you keep all of your apps in /apps/ make sure you are in /apps/my_app before calling the server command.
The Ruby bundled with OS X is too old for Rails 3.
I would recommended using 'rvm' to install the latest stable version of ruby-1.9.2-p260
Since installing ruby requires some compilation, make sure you have a gcc installed. You can install XCode to get an usable gcc.
To install rvm, you need bash, git and curl.
RVM: http://beginrescueend.com/
After that, you can use
gem install rails
Enjoy!
The Lion Server looks at a non-default path for the gem file
For example have a look at the first line of /usr/share/devicemgr/backend/devicemgrd:
#!/usr/bin/env GEM_HOME=/usr/share/devicemgr/webserver/gems GEM_PATH=/usr/share/devicemgr/webserver/gems RAILS_ENV=production /usr/bin/ruby
So to install the missing gems, make sure to install them at the required path:
sudo GEM_HOME=/usr/share/devicemgr/webserver/gems gem install rails

Problem installing Heroku with Rails3, Ruby 1.9.2

I am using Ubuntu 10.10, RVM and Ruby 1.9.2 and trying to install Heroku for the first time. Ruby 1.9.2 is the default for RVM and the only version I have been using.
The gem install heroku worked but trying to run heroku leads to "command not found" error. The executables folder /home/mike/.rvm/gems/ruby-1.9.2-p0/bin is already in the PATH. However, I see that Heroku was installed in /var/lib/gems/1.8/gems. gem list heroku does not show any installed gem. Simply creating symbolic links in .../ruby-1.9.2-p0 did not solve the problem, though it gives a different error:
/usr/lib/ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem heroku (>= 0) (Gem::LoadError)
from /usr/lib/ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:1082:in `gem'
from /home/mike/.rvm/gems/ruby-1.9.2-p0/bin/heroku:18
I don't understand gem and rvm well enough to know what to try next. I read in another question that Heroku supports Ruby 1.9.1 but not 1.9.2 but don't know if that is still true. If so, how does one use Rails and Ruby 1.9.x with Heroku?
The problem turned out to be related to sudo and Ubuntu. RVM depends on the rvm_path environment variable to get started. According to answers to another question, sudo does not preserve the PATH variable in some versions of secure Linux. I don't know if it should ever preserve the rvm_path variable, but in any case, it does not on my version of Ubuntu. So the result of sudo gem install is that the default, RVM-provided version of Ruby is not available during the installation, and the system-default is used. In my case that is version 1.8. The installation appears to succeed, but it is not going to the right gem version.
The solution was simply to use gem install instead of sudo gem install.
If 'gem list' doesn't show the Heroku gem then that would seem to be the problem (the error you posted occurs when running a Heroku command without the gem installed).
Have you tried installing it again? Any error messages?
It does work with 1.9.2.
Had the exact same problem on Mac OSX 10.6.5. Reinstalling without sudo worked in this case also. Thanks for the explanation... being a nube, I would have never figured it out.

Rails 3: Ruby 1.9.2: does it need /usr/bin/ruby1.8?

I am trying to get the Rails tutorial by Michael Hartl going. I spent a lot of time fighting various libraries. So I removed all ruby software from my Ubuntu 10.4 system.
Then I installed Ruby 1.9.2.
$ ruby -v
ruby 1.9.2dev (2010-07-02) [i486-linux]
So far so good. Then I did
sudo gem install rails
After a long time, it finished the installation.
Then I ran
$ rails -v
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
So...I have no /usr/bin/ruby1.8 on my system. How do I get Rails 3.0.3 to use my ruby at /usr/bin/ruby?
I appreciate any help you can give me.
Just to see if I could keep going, I tried
$ cd /usr/bin
$ sudo ln -s ruby1.9.2 ruby1.8
This let me keep going, but is it the right thing to do?
It took trying 3 different methods of installing and uninstalling Ruby, but I finally got it!
I found a great tutorial by Toran Billups which gives some great instructions. After analyzing what he did, it comes down to a few key concepts:
Some libraries that are independent of the Ruby version must be installed in the system (using "sudo apt-get").
Use RVM to install Ruby in your own account. i.e. no "sudo".
Use gem to install gems in your particular ruby environment. (i.e. no "sudo"). When you set 1.8 as the Ruby environment, the gems are installed in the RVM 1.8 tree in your environment. When you set 1.9.2 as the environment, gems are installed in the 1.9.2 tree in your environment.
Here, then, is the process.
Remove all Ruby programs (1.8.x and 1.9.2) and Ruby libraries from your Ubuntu 10.4 system.
Install RVM on your system, following the instructions at the RVM site(broken) RVM site.
Follow Toran Billups' tutorial, starting at the point where you install Ruby 1.8.7.
Follow the instructions at Michael Hartl's tutorial(broken) Michael Hartl's tutorial to get Rails 3.0 working with Ruby 1.9.2, github, heroku.com, rspec, spork, and autotest.
I had the same error after installing with RVM and opening new shells. The solution was to run:
$ rvm use 1.9.2 --default
P.S.
I'm running Ubuntu 10.04 and after two days of trial and error finally got rails 3 working with ruby 1.9.2. I highly recommend using RVM to install ruby a godsend!
By the sounds of it Bash is finding ruby1.8 when its running the #!/usr/bin/env ruby line from the rails script, even though it doesn't exist. Try /usr/bin/env which ruby to see exactly what interpreter it's trying to load.
I was also having a headache with this, and don't want to use RVM right now.
I saw that the shebang line for /usr/bin/gem was #!/usr/bin/ruby1.8 and that this was presumably the issue.
I made sure /etc/alternatives pointed to the correct gem script; this can be set with:
update-alternatives --config gem
Then I removed /usr/bin/gem and symlinked from /usr/bin/gem to /etc/alternatives/gem
It turns out the only difference in the gem scripts was the shebang line, so manually changing that would have worked too.
Solved by changing back the version of my current Ruby (using RVM) to 2.0.x.
When i installed rails (two days ago) it was under the 2.0.0 version. Yesterday i changed to 2.1.x. Today i tried the rails command and got the error.
So turning back to the RVM Ruby version i installed rails did the trick.
Sorry by the bad english.
P.S. Using Ubuntu 13.10