未能在OSX上设置(我自己的)预构建的Rails应用程序

时间:2015-07-19 04:02:41

标签: ruby-on-rails ruby macos ruby-on-rails-3 gem

完成Rails Tutorial之后我想将其扩展到个人应用程序中,因此我创建了另一个目录并将所有文件从 tutorialFolder 移动/复制到 appFolder

然而,当我尝试再次设置宝石时,我遇到了一些问题。

bundle install返回:

An error occurred while installing pg (0.17.1), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

所以我尝试gem install pg -v '0.17.1(或bundle update)并获取:

You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

搜索StackOverflow我发现了Installing gem or updating RubyGems fails with permissions error

其中解释了/Library/Ruby/Gems/2.0.0

  

这是Apple安装的Ruby版本,供自己使用。如果您知道自己在做什么,可以对其进行微小的修改,但是由于您不确定权限问题,我说这不是一个好主意。沿着那条赛道继续前进。

为了避免上述情况,我尝试brew install ruby成功,但卡在bundle install

我无法追溯到哪里,但我也试图删除Gemfile.lock但是没有做任何事情。

其他信息:ruby -v>>> ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

rails -v>>> bin/spring:10:in 'read': No such file or directory - /Gemfile.lock (Errno::ENOENT)

bundle install --path vendor/bundle>>> An error occurred while installing pg (0.17.1), and Bundler cannot continue.

谢谢,

编辑*我尝试从头开始使用rails new app然而得到了这个:

Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
run  bundle exec spring binstub --all
/Library/Ruby/Gems/2.0.0/gems/bundler-         1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find  i18n-0.7.0 in any of the sources (Bundler::GemNotFound)
from /Library/Ruby/Gems/2.0.0/gems/bundler-  1.10.5/lib/bundler/spec_set.rb:85:in `map!'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

以上版块已使用rvm gemset empty修复,然后我可以设置VANILLA rails应用,仍然无法与教程结束同步

2 个答案:

答案 0 :(得分:0)

听起来你试图通过复制所有文件来创建rails应用程序的副本。我会做的

-(void)viewWillDisppear:(BOOL)animated {
    [super viewWillDisppear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];

}

要使用rails设置创建新目录,只需复制rails new appFolder 中的所有文件以替换tutorialFolder中的文件。

答案 1 :(得分:0)

从rails this section开始,我添加了以下代码:

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

解释
  

还要注意添加了rails_12factor gem,Heroku使用它来提供静态资源,如图像和样式表。生成的Gemfile如清单1.14所示。

     

要准备系统部署到生产,我们运行bundle   使用特殊标志安装以防止本地安装任何   生产宝石(在这种情况下由pg和   rails_12factor):

bundle install --without production

一切正常。