Ubuntu 10 Ruby 1.9 Rails 3 not working?

别等时光非礼了梦想. 提交于 2019-12-05 02:06:02

问题


Hi hope there is someone out there that can help me, have been struggling with this for quite some time now. Im running Ubuntu 10 on the dev machine wich had ruby 1.8 on it, wich I removed. I installed Ruby 1.9.3 and rails3 using RVM and this tutorial http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/


when I type ruby -v I get
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]

wich seems correct

I created a new test app using

rails new mysite

wich created the new app successfully then I

cd mysite

and created a gemset

rvm gemset create 'rails3'

then I used this inside the /mysite/ folder

rvm use 1.9.3@rails3 --rvmr
Using /usr/local/rvm/gems/ruby-1.9.3-p125 with gemset rails3

but the problem arises when i try to run it

root@server-pc:/var/www/mysite# rails s
-bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory

EDIT1:

root@server-pc:/var/www/mysite# which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby

回答1:


log in as root user


remove old ruby

list ruby packeges

dpkg -l | grep ruby

then remove all ruby packeges

aptitude purge <package name>

if you have rvm installed

rvm remove all

then

rvm implode

or

rvmsudo rvm implode

install ruby

still logged in as root

install all of the necessary tools and libraries

apt-get install curl git-core build-essential zlib1g-dev libssl-dev libreadline5-dev

install rvm

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Then add this line as the last line in your .bashrc:

nano ~/.bash_profile

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi

test RVM install

rvm notes

Next, you can begin ruby 1.9.2 installation by running

rvm install 1.9.2

The install will take up to several minutes and once it completes you have to set ruby 1.9.2 as the default version

rvm --default ruby-1.9.2

test your new ruby install ruby -v

install Rails 3

gem install rails

If you want to get a quick database up and running with sqlite, then you’ll need to sqlite3 and the libsqlite3-dev packages

apt-get install sqlite3 libsqlite3-dev

gem install sqlite3-ruby

create new app

rails new testapp

cd testapp

Make sure you are in your test app directory and run

rails s

Open your browser at http://localhost:3000




回答2:


well, I believe this line:

-bash: /usr/bin/rails: /usr/bin/ruby1.8

means that you already have a /usr/bin/rails binary which is using ruby1.8 interpreter. Try moving it somewhere:

mv /usr/bin/rails /usr/bin/rails-1.8

then go to your project directory, and bundle install.

if you already have the rails bundled, try reinstalling the gems.



来源:https://stackoverflow.com/questions/9563656/ubuntu-10-ruby-1-9-rails-3-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!