简体   繁体   English

Rails应用无法检测本地宝石

[英]Rails app cant detect local gems

This is a very odd one and I'm not sure how to proceed. 这是一个很奇怪的问题,我不确定如何进行。

Basically, I am able to install gems and use them normally within any folder except those created with rails. 基本上,我可以安装gem并在除rails创建的文件夹之外的任何文件夹中正常使用它们。 It's very very odd. 非常非常奇怪。 It's difficult to explain so maybe this console output will explain 很难解释,所以也许此控制台输出将解释

    passenger@rubyserve:~/railsapps$ ls
    app  test_application  testing
    passenger@rubyserve:~/railsapps$ rails -v
    Rails 3.2.2
    passenger@rubyserve:~/railsapps$ 
    passenger@rubyserve:~/railsapps$ 
    passenger@rubyserve:~/railsapps$ cd app/
   passenger@rubyserve:~/railsapps/app$ ls -a
   .   app     config.ru  doc      Gemfile.lock  lib  public    README.rdoc  test  vendor
   ..  config  db         Gemfile  .gitignore    log  Rakefile  script       tmp
    passenger@rubyserve:~/railsapps/app$ 
    passenger@rubyserve:~/railsapps/app$ 
    passenger@rubyserve:~/railsapps/app$ rails -v
    The program 'rails' is currently not installed.  To run 'rails' please ask your administrator to install the package 'rails'
    passenger@rubyserve:~/railsapps/app$ 

It makes bugger all sense. 这使臭虫变得很有意义。 When outside my rails folder, I can call rails to make a new application but once within, rails isn't detected. 在rails文件夹外时,我可以调用rails来创建新应用程序,但是一旦进入,就不会检测到rails。 This is the same for all gems including bundler. 所有宝石(包括捆扎机)都是相同的。

My first thought was that somehow, rails had some specific gem folder hidden away, so I done my gem install from within the rails project, however this didn't work either. 我首先想到的是,Rails隐瞒了一些特定的gem文件夹,所以我从rails项目中完成了gem的安装,但是这也不起作用。

Any thoughts? 有什么想法吗?


My setup is ubuntu server 10.10 (I know, i know) Ruby 1.9.2 gem 1.8.17 and I'm using the latest rvm from wayneeseguin. 我的设置是ubuntu服务器10.10(我知道,我知道)Ruby 1.9.2 gem 1.8.17,我正在使用wayneeseguin的最新rvm。 enter code here

This type of problem some time occurs i think u can save a lot of time by installing and using RVM 我认为您可以通过安装和使用RVM节省很多时间

After installing RVM create gemset directory every time whenever you create separate project. 安装RVM后,每当您创建单独的项目时,都要创建gemset目录。 eg you create application blog first you create gemset directory with giving this command 例如,您首先创建应用程序博客,然后使用以下命令创建gemset目录

rvm gemset create blog

then you should use this gemset directory and also ruby version as well eg you have install ruby 1.9.2 then use this command 那么您应该使用该gemset目录以及ruby版本,例如,您已经安装ruby 1.9.2然后使用此命令

rvm use ruby-1.9.2@blog

after that go into directory of blog application and install this gem 之后,进入博客应用程序目录并安装此gem

gem install bundler

and also then bundle install . 然后bundle install so all local gem will be installed into this blog directory under rvm and there will be no conflicts will be appear.But keep one thing in mind if your platform is ubuntu then this will work 因此所有本地gem都将安装到rvm下的此博客目录中,并且不会出现任何冲突。但是请记住一件事,如果您的平台是ubuntu,那么它将起作用

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

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