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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8410885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:27:30  来源:igfitidea点击:

How do I install Ruby with libyaml on Ubuntu 11.10?

ruby-on-railsrubyrubygems

提问by qian qian

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,然后安装了 ruby​​gems 来设置 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. The information changed and I have no idea what's wrong with it.

我安装了 libyaml 并重新安装了 Ruby,但仍然无法正常工作。信息改变了,我不知道有什么问题。

回答by WebsoftFreelance

You must install the paquage libyaml-dev before installing ruby, if not you can still use extconf.rb for the missing library. So for this problem you can do (from the ruby install folder) :

您必须在安装 ruby​​ 之前安装 paquage libyaml-dev,如果没有,您仍然可以使用 extconf.rb 来获取缺少的库。因此,对于此问题,您可以执行以下操作(从 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​​ 后添加库。

回答by mosid

Do the following:

请执行下列操作:

  1. you must have "curl" installed :sudo apt-get install curl
  2. Go To this link 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
  5. Type ~/.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
  7. Type: rvm install 1.9.3-p0
  8. Type: rvm use 1.9.3-p0
  9. Type: gem install rails
  10. Have fun :)
  1. 您必须安装“curl”:sudo apt-get install curl
  2. 转到此链接RVM
  3. 复制快速安装框中的命令并将其粘贴到命令提示符中
  4. 类型 echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
  5. 类型 ~/.bashrc
  6. 输入以下代码: 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. 类型: rvm install 1.9.3-p0
  8. 类型: rvm use 1.9.3-p0
  9. 类型: gem install rails
  10. 玩得开心 :)

回答by PleaseHelpTheNewGuy

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"

[[ -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

After executing above command you should be getting this output - rvm is a function

执行上述命令后,你应该得到这个输出 - rvm 是一个函数

You've successfully installed the RVM. Next, you are supposed to install additional dependencies. To find out those programs type -

您已成功安装 RVM。接下来,您应该安装其他依赖项。要找出这些程序类型 -

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:~$ rails new test_app

me@Box:~$ cd test_app

me@Box:~$ cd test_app

me@Box:~/test_app$ rails server

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). Time to get going with some Rails! :D

我不明白为什么它将 0.0.0.0:3000 设置为主机地址(我认为它会是 127.0.0.1),但坦率地说,这并没有打扰我现在 - 我让它工作(到目前为止)。是时候开始使用一些 Rails 了!: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! I wasn't sure what was considered "code" and apparently the prompt is considered code. Makes sense now :)

注2:仅发布答案的神圣学习曲线!我不确定什么被认为是“代码”,显然提示被认为是代码。现在有意义:)

Note3: This is my first "Answer" on StackOverflow! :D

注3:这是我在 StackOverflow 上的第一个“答案”!:D

回答by Joseph Le Brech

If you are compiling ruby you might need libyaml-dev

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

回答by andrew12

Debian (and Ubuntu, etc.) packages that contain the files needed to install some other program from source usually end in -dev, e.g. libyaml-dev, so try installing that. Or just use rvm, it will actually install this for you.

包含从源代码安装其他程序所需的文件的 Debian(和 Ubuntu 等)软件包通常以-dev,例如结尾libyaml-dev,因此请尝试安装它。或者只是使用rvm,它实际上会为您安装它。

回答by MT.

Compling yaml from its source will make it work. 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/. It definitely works.

从源代码编译 yaml 将使其工作。我正在运行与您相同的配置。我跟着这个http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/。它绝对有效。