使用 RVM 创建 Rails3 应用程序时出现错误(“当前未安装程序‘rails’。”)

发布于 2024-12-04 11:34:21 字数 2351 浏览 1 评论 0原文

我使用的是 Ubuntu 11 尝试安装rails 3.1 好像我安装了rails,但后来我无法使用它。 我想使用 rvm 来安装和使用 Rails,但我不想走 sudo apt-get 路线。

谢谢!

durrantm@castleLinux2011:~$ rvm list rubies

rvm rubies

   ruby-1.9.2-p290 [ x86_64 ]

durrantm@castleLinux2011:~$ rvm use --create 1.9.2@rails3
Using /home/durrantm/.rvm/gems/ruby-1.9.2-p290 with gemset rails3
durrantm@castleLinux2011:~$ rvm list rubies

rvm rubies

=> ruby-1.9.2-p290 [ x86_64 ]

durrantm@castleLinux2011:~$ gem install rails
    ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
    ERROR:  While executing gem ... (NameError)
        uninitialized constant Gem::Commands::InstallCommand
    durrantm@castleLinux2011:~$ sudo gem install rails
    Successfully installed rails-3.1.0
    1 gem installed
    Installing ri documentation for rails-3.1.0...
    file 'lib' not found
    Installing RDoc documentation for rails-3.1.0...
    file 'lib' not found
    durrantm@castleLinux2011:~$ rails
    The program 'rails' is currently not installed.  You can install it by typing:
    sudo apt-get install rails
    durrantm@castleLinux2011:~$ 

顺便说一句,

durrantm@castleLinux2011:~$ gem install rails
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
durrantm@castleLinux2011:~$ 

也不起作用,我已经围绕 zlib 问题讨论了大约一个小时。

还:

rvm gemset install rails
installing rails ...
ERROR: Error running 'GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3'  gem install rails    ', please read /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
rails  failed to install ( output logged to: /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log )
durrantm@castleLinux2011:~$ tail -20 /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
[2011-09-13 09:17:57] GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3'  gem install rails    
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
durrantm@castleLinux2011:~$ 

I'm on Ubuntu 11
Tring to install rails 3.1
It seems like I install rails but then I can't use it.
I want to use rvm to install and use rails and I do not want to go the sudo apt-get route.

Thanks!

durrantm@castleLinux2011:~$ rvm list rubies

rvm rubies

   ruby-1.9.2-p290 [ x86_64 ]

durrantm@castleLinux2011:~$ rvm use --create 1.9.2@rails3
Using /home/durrantm/.rvm/gems/ruby-1.9.2-p290 with gemset rails3
durrantm@castleLinux2011:~$ rvm list rubies

rvm rubies

=> ruby-1.9.2-p290 [ x86_64 ]

durrantm@castleLinux2011:~$ gem install rails
    ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
    ERROR:  While executing gem ... (NameError)
        uninitialized constant Gem::Commands::InstallCommand
    durrantm@castleLinux2011:~$ sudo gem install rails
    Successfully installed rails-3.1.0
    1 gem installed
    Installing ri documentation for rails-3.1.0...
    file 'lib' not found
    Installing RDoc documentation for rails-3.1.0...
    file 'lib' not found
    durrantm@castleLinux2011:~$ rails
    The program 'rails' is currently not installed.  You can install it by typing:
    sudo apt-get install rails
    durrantm@castleLinux2011:~$ 

btw

durrantm@castleLinux2011:~$ gem install rails
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
durrantm@castleLinux2011:~$ 

doesn't work either and I have danced around the zlib issue for about an hour.

Also:

rvm gemset install rails
installing rails ...
ERROR: Error running 'GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3'  gem install rails    ', please read /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
rails  failed to install ( output logged to: /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log )
durrantm@castleLinux2011:~$ tail -20 /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
[2011-09-13 09:17:57] GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290@rails3'  gem install rails    
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
durrantm@castleLinux2011:~$ 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅紫色的梦幻 2024-12-11 11:34:21

不不,没有rvmsudo。

rvm pkg 安装 zlib && rvm install 1.9.2(因此它是针对 rvm 安装的 zlib 构建的)&& rvm --create use 1.9.2@rails31(创建一个rails31 gemset并一次性使用它)

注意:如果您最初使用rvm install 1.9.2进行安装,请使用rvm install 1.9.2。 -p290 出现是因为 ruby​​ 项目的官方版本有 290,而 rvm 会采用这一事实。这样,当 1.9.2 系列被跳转时,使用 1.9.2 而不是 1.9.2-p290,rvm 将选择它并安装它。否则,如果您最初执行“rvm install 1.9.2-p290”,则改为执行此操作。

至于rails命令。如果您执行了上述命令,那么您已进入正确的 rvm 控制的 ruby​​ 和 gemset。如果没有,那么现在执行该命令(rvm --create use 1.9.2@rails31)

现在你可以执行 gem install Rails -v='3.1.0' (我添加了版本,以防在你看到这个之前 Rails 发生变化

)将把rails gem 及其依赖项安装到Ruby 1.9.2-p290 的rails31 gemset 中。现在你可以执行rails new test_app来测试它。 (我通常 mkdir -p $HOME/tmp && cd $HOME/tmp &&rails new test_app)

这应该可以消除您的问题。

no no, no rvmsudo.

rvm pkg install zlib && rvm install 1.9.2 (so it builds against that zlib that rvm installed) && rvm --create use 1.9.2@rails31 (to create a rails31 gemset and use it all on one go)

NOTE: use rvm install 1.9.2 if you used that to install originally. the -p290 shows up because it is a result of the fact that the ruby project has 290 as the official release and rvm picks up on that. This way with 1.9.2 and not 1.9.2-p290 when 1.9.2 series is jumped, rvm will pick up on that and install that instead. Otherwise if you originally did 'rvm install 1.9.2-p290' then do that instead.

As for the rails command. If you executed the above commands then you have been moved into the right rvm controlled ruby and gemset. If not then execute that command now (rvm --create use 1.9.2@rails31)

NOW you can execute gem install rails -v='3.1.0' (I added the version just in case rails changes before you see this)

This will install the rails gem and its deps into Ruby 1.9.2-p290's rails31 gemset. Now you can execute rails new test_app to test it. (I usually mkdir -p $HOME/tmp && cd $HOME/tmp && rails new test_app)

This should eliminate your problems.

前事休说 2024-12-11 11:34:21

您需要重新安装红宝石。请按照 http://beginrescueend.com/packages/zlib/ 中的说明进行操作。

您可能会在使用 readline 或 openSSL 时遇到同样的问题,请检查 rvm 网站,因为它们也为这些库提供了一些解决方法。

You need to reinstall ruby. Follow the instructions in http://beginrescueend.com/packages/zlib/.

You might get the same problem with readline or openSSL, check the rvm website as they provide some workarounds for those libraries too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文