简体   繁体   English

如何在Ubuntu 11.10上使用libyaml安装Ruby?

[英]How do I install Ruby with libyaml on Ubuntu 11.10?

I installed ruby-1.9.3-p0 on my Ubuntu 11.10 wubi and then rubygems to get Rails set up. 我在Ubuntu 11.10 wubi上安装了ruby-1.9.3-p0,然后在rubygems上安装了Rails。

This is my code: 这是我的代码:

sudo ruby setup.rb

I got this error: 我收到此错误:

"/usr/local/lib/ruby/1.9.1/yaml.rb:56:in'<top(required)>':
It seems your ruby installation is missing psych (for YAML output). 
To eliminate this warning, please install libyaml and reinstall your ruby."

I installed libyaml and reinstalled Ruby but still it doesn't work. 我安装了libyaml并重新安装了Ruby,但仍然无法正常工作。 The information changed and I have no idea what's wrong with it. 信息已更改,我不知道这是怎么回事。

You must install the paquage libyaml-dev before installing ruby, if not you can still use extconf.rb for the missing library. 您必须在安装ruby之前安装paquage libyaml-dev,否则您仍然可以对缺少的库使用extconf.rb。 So for this problem you can do (from the ruby install folder) : 因此,对于这个问题,您可以执行以下操作(从ruby安装文件夹):

cd ext/psych
ruby extconf.rb
make
make install

Extconf.rb is usefull for adding a library after have installed ruby. Extconf.rb对于在安装ruby之后添加库很有用。

Do the following: 请执行下列操作:

  1. you must have "curl" installed : sudo apt-get install curl 您必须安装“ curl”: sudo apt-get install curl
  2. Go To this link RVM 转到此链接RVM
  3. Copy the command in the quick install box and Paste it in your command prompt 将命令复制到快速安装框中,然后将其粘贴到命令提示符中
  4. Type echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc 键入echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
  5. Type ~/.bashrc 键入~/.bashrc
  6. Type the following code: sudo apt-get install build-essential libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion 键入以下代码: sudo apt-get install build-essential libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
  7. Type: rvm install 1.9.3-p0 类型: rvm install 1.9.3-p0
  8. Type: rvm use 1.9.3-p0 类型: rvm use 1.9.3-p0
  9. Type: gem install rails 类型: gem install rails
  10. Have fun :) 玩得开心 :)

Ok, after a failed attempt at installing RoR on my Ubuntu 11.10 box, I combined the tips from this page and from this resource: http://www.thegeekwork.com/how-to-install-ruby-on-rails-in-ubuntu-11-10/ 好的,在我的Ubuntu 11.10机器上尝试安装RoR失败后,我结合了此页面和以下资源的提示: http : //www.thegeekwork.com/how-to-install-ruby-on-rails-in -ubuntu-11-10 /

This is the breakdown, step-by-step of what I just did to make this work (sorry if I didn't format this so great, I was just trying to keep it neat): 这是我为完成这项工作所做的详细的逐步介绍(很抱歉,如果我没有将其格式化得如此出色,我只是想使其保持整洁):

1) Fresh install of Ubuntu 11.10 1)全新安装Ubuntu 11.10

2) me@Box:~$ sudo apt-get install curl 2) me@Box:~$ sudo apt-get install curl

3) me@Box:~$ sudo apt-get install git 3) me@Box:~$ sudo apt-get install git

4) me@Box:~$ sudo apt-get update 4) me@Box:~$ sudo apt-get update

5) me@Box:~$ sudo apt-get dist-update 5) me@Box:~$ sudo apt-get dist-update

6) me@Box:~$ sudo shutdown -r now 6) me@Box:~$ sudo shutdown -r now

7) me@Box:~$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) 7) me@Box:~$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

8) me@Box:~$ gedit ~/.bashrc 8) me@Box:~$ gedit ~/.bashrc

9) add the following line to the end (and save the file) 9)将以下行添加到末尾(并保存文件)

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

10) me@Box:~$ source ~/.bashrc 10) me@Box:~$ source ~/.bashrc

11) me@Box:~$ type rvm | head -1 11) me@Box:~$ type rvm | head -1 me@Box:~$ type rvm | head -1

After executing above command you should be getting this output - rvm is a function 执行完以上命令后,您应该会得到以下输出-rvm是一个函数

You've successfully installed the RVM. 您已经成功安装了RVM。 Next, you are supposed to install additional dependencies. 接下来,应该安装其他依赖项。 To find out those programs type - 要找出这些程序,请输入-

12) me@Box:~$ rvm requirements 12) me@Box:~$ rvm requirements

After the above command, install the additional packages recommended by RVM - 完成上述命令后,安装RVM建议的其他软件包-

13) me@Box:~$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion 13) me@Box:~$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

14) me@Box:~$ rvm install 1.9.2 14) me@Box:~$ rvm install 1.9.2

(#14 takes a little while) (#14需要一些时间)

15) me@Box:~$ rvm use 1.9.2 15) me@Box:~$ rvm use 1.9.2

(This selects the version you want to use) (这将选择您要使用的版本)

(If you aren't sure about the ruby version currently being used, then type - ruby -v) (如果不确定当前使用的ruby版本,请键入-ruby -v)

16) me@Box:~$ gem install rails 16) me@Box:~$ gem install rails

(this will take a little while...) (这需要一些时间...)

17) Make a sample application as a test... 17)做一个示例应用程序作为测试...

me@Box:~$ rails new test_app

me@Box:~$ cd test_app

me@Box:~/test_app$ rails server

AND THAT"S WHERE THIS THING DIDN"T WORK. 而这在哪里行不通。 ARRRRRRRRRrrrrrrrrrrrrrgh. ARRRRRRRRRrrrrrrrrrrrrrgh。

So, 所以,

18) in your application folder ("test_app"), open Gemfile and uncomment "therubyracer" line 18)在您的应用程序文件夹(“ test_app”)中,打开Gemfile并取消注释“ therubyracer”行

19) me@Box:~/test_app$ bundle install 19) me@Box:~/test_app$ bundle install

20) me@Box:~/test_app$ rails server 20) me@Box:~/test_app$ rails server

Done, and done. 做完了。

I don't understand why it set 0.0.0.0:3000 as the host address (I thought it would be 127.0.0.1), but quite frankly, that's not bothering me right now -- I got it to work (so far). 我不明白为什么将0.0.0.0:3000设置为主机地址(我认为应该是127.0.0.1),但是坦率地说,这现在并没有困扰我-我已经可以使用它了(到目前为止)。 Time to get going with some Rails! 是时候开始使用Rails了! :D :D

I hope this helps anyone else who is looking to make this work! 希望这对其他希望实现此目的的人有所帮助! :) :)

Note: I realize that #13 repeats some of the things I already installed, but I don't care, I'm just doing what the thing says. 注意:我意识到#13重复了一些我已经安装的事情,但是我不在乎,我只是按照事情说的去做。 :/ :/

Note2: Holy learning curve on just posting an answer! 注意2:只需发布答案就可以了! I wasn't sure what was considered "code" and apparently the prompt is considered code. 我不确定什么被认为是“代码”,显然提示被认为是代码。 Makes sense now :) 现在有意义:)

Note3: This is my first "Answer" on StackOverflow! 注意3:这是我在StackOverflow上的第一个“答案”! :D :D

如果您正在编译ruby,则可能需要libyaml-dev

Debian (and Ubuntu, etc.) packages that contain the files needed to install some other program from source usually end in -dev , eg libyaml-dev , so try installing that. Debian(和Ubuntu等)软件包包含从源代码安装其他程序所需的文件,通常以-dev结尾,例如libyaml-dev ,因此请尝试安装。 Or just use rvm , it will actually install this for you. 或只使用rvm ,它实际上会为您安装此程序。

Compling yaml from its source will make it work. 从源代码编译yaml将使其起作用。 I am running the same config as yours. 我正在运行与您相同的配置。 I followed this http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/ . 我遵循了这个http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/ It definitely works. 绝对可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM