Ruby-on-rails 安装 Rails:“找不到文件:lib”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4822052/
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 00:13:16  来源:igfitidea点击:

Installing Rails: "File not found: lib"

ruby-on-railsrubyubuntu

提问by Phil

Whenever I try to install Rails on Ubuntu Server, I get the error, File not found: lib. Why is this?

每当我尝试在 Ubuntu Server 上安装 Rails 时,都会收到错误消息,找不到文件:lib。为什么是这样?

回答by imwilsonxu

Ubuntu 11.10, ruby 1.9.3p125, gem ruby 1.9.3p125

Ubuntu 11.10,红宝石 1.9.3p125,宝石红宝石 1.9.3p125

gem install rdoc
gem install rails

回答by Amin Ariana

I had the exact same problem. I tried the other solution suggested here and that didn′t work for me on Ubuntu.

我有同样的问题。我尝试了此处建议的其他解决方案,但在 Ubuntu 上对我不起作用。

Here is the solution:

这是解决方案:

Ubuntu

Ubuntu

mkdir /lib/ruby/gems/1.8/gems/rails-{whatever your version is}/lib

mkdir /lib/ruby/gems/1.8/gems/rails-{whatever your version is}/lib

Depending on which combination of environment versions you're using, some users have given the feedback that this works for them instead:

根据您使用的环境版本组合,一些用户给出的反馈是这对他们有用:

mkdir /var/lib/gems/1.8/gems/rails-{whatever your version is}/lib

mkdir /var/lib/gems/1.8/gems/rails-{whatever your version is}/lib

Basically, the ¨[sudo] gem install rails¨ command expects the /lib folder (at the end) but for some reason it hasn′t been created yet.

基本上,¨[sudo] gem install rails¨ 命令需要 /lib 文件夹(在最后),但由于某种原因它还没有被创建。

If you're not sure what your rails version is for the part where I say {whatever your version is}, type up to "rails-" and then try hitting the tab button. You're on a Linux system, so it'll give you a suggestion or two. If it doesn't, try the alternative line given above. You'll need some try and error here because the directory structure is slightly varied in different versions of rails, it seems.

如果你不确定你的 rails 版本是什么,我说{whatever your version is},输入“rails-”,然后尝试点击标签按钮。您使用的是 Linux 系统,因此它会给您一两个建议。如果没有,请尝试上面给出的替代行。在这里,您需要进行一些尝试和错误,因为不同版本的 rails 中的目录结构似乎略有不同。

The source of this solution was the following URL. Hope it helps!

此解决方案的来源是以下 URL。希望能帮助到你!

http://www.spritle.com/blogs/?p=915

http://www.spritle.com/blogs/?p=915

Mac OS X

Mac OS X

If you're having a similar problem on Mac OS X, take a look at this other post as well. Sounds like your work-around is simpler:

如果您在 Mac OS X 上遇到了类似的问题,请查看另一篇文章。听起来您的解决方法更简单:

Ruby on Rails Beta 3 Install Problem on Snow Leopard

Ruby on Rails Beta 3 在 Snow Leopard 上安装问题

回答by Amokrane Chentir

Google has lots of information about this error. You can read thisor this..or browse more

谷歌有很多关于这个错误的信息。您可以阅读..或浏览更多

EDIT

编辑

Found these on Stackoverflow itself: rails 3 install error "File not found: lib"and the original one: Ruby on Rails Beta 3 Install Problem on Snow Leopard

在 Stackoverflow 上找到了这些:rails 3 install error "File not found: lib"和原始错误Ruby on Rails Beta 3 Install Problem on Snow Leopard

To summarize you need to run gem install rdocbefore.

总而言之,您需要先运行gem install rdoc

It might solve your problem!

或许能解决你的问题!

回答by Zaz

I had the same problem. I kept receiving the following error message:

我有同样的问题。我不断收到以下错误消息:

$ sudo gem install rails
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
File not found: lib

After a lot of messing around reinstalling ruby and googling for answers I finally came across Amin Ariana's answer, upon which I ran sudo mkdir /var/lib/gems/1.8/gems/rails-3.0.7/lib/.

在重新安装 ruby​​ 和谷歌搜索答案后,我终于找到了 Amin Ariana 的答案,我跑了sudo mkdir /var/lib/gems/1.8/gems/rails-3.0.7/lib/

Success! Everything now works as expected:

成功!现在一切都按预期工作:

$ sudo gem install rails
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for rails-3.0.7...

According to a similar StackOverflow answer, running sudo gem install rdochas the same effect.

根据类似的 StackOverflow answer,运行sudo gem install rdoc具有相同的效果。

NOTE: To actually run rails after installing via gem rather than apt, you'll need to add the gem library to your path in your ~/.bashrc: /var/lib/gems/1.8/bin

注意:要在通过 gem 而不是 apt 安装后实际运行 rails,您需要将 gem 库添加到您的路径中~/.bashrc/var/lib/gems/1.8/bin

回答by Denis de Bernardy

As I understand it, the actual issue lies within rubygems:

据我了解,实际问题在于 ruby​​gems:

https://github.com/rails/rails/issues/1958

https://github.com/rails/rails/issues/1958

https://github.com/rails/rails/commit/e7fc5d1cad27e47d3d0149a2b9a61d074c30f225

https://github.com/rails/rails/commit/e7fc5d1cad27e47d3d0149a2b9a61d074c30f225

The default s.require_pathsis, in as far as I can tell by the commit to fix the issue, [lib]rather than []. So you end up with libnot found errors whenever you install a gem without such a folder.

默认s.require_paths是,据我所知,修复问题的提交,[lib]而不是[]. 因此,lib每当您安装没有此类文件夹的 gem 时,您最终都会遇到 not found 错误。

Rails in particular, but not only.

尤其是 Rails,但不仅如此。

回答by tknv

# sudo gem install rdoc
# sudo gem install rdoc-data
# sudo vim /var/lib/gems/1.8/gems/rdoc-data-2.5.3/bin/rdoc-data

rdoc-data version 2.5.3 is depend on your version. My Marveric ruby path is /usr/bin/ruby, But my rdoc-data ruby path wasn't. Then I change it.

rdoc-data 版本 2.5.3 取决于您的版本。我的 Marveric ruby​​ 路径是 /usr/bin/ruby,但我的 rdoc-data ruby​​ 路径不是。那我改一下。

EDIT/

编辑/

#!/usr/bin/ruby -w

require 'rubygems'
require 'rdoc/data'

RDoc::Data.run

/EDIT

/编辑

# sudo /var/lib/gems/1.8/gems/rdoc-data-2.5.3/bin/rdoc-data --install
# sudo gem rdoc --all --overwrite
# sudo mkdir -p /var/lib/gems/1.8/gems/rails-3.0.6/lib
# sudo gem rails

Good luck!

祝你好运!