与pg gem一起使用Rails和bundle安装错误?

时间:2015-05-20 02:03:37

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

我正在尝试在我的MacBook Pro上安装Ruby on Rails,运行Yosemite 10.10作为我的学校计划。我已经成功安装了所有东西但是现在当我运行rails时我得到了这个错误。我试图继续使用bundle install来解决问题但是你可以看到它不起作用。这里发生了什么?我接着尝试使用sudo,但它也失败了。

▶ rails s
Could not find pg-0.18.1 in any of the sources
Run `bundle install` to install missing gems.

~/code/Bloccit  master ✔                                                                                                                                              2d  ⍉
▶ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Using CFPropertyList 2.3.1
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.6.0
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.1
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.0
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.5
Using activejob 4.2.1
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1
Using execjs 2.5.2
Using autoprefixer-rails 5.1.9
Using bcrypt 3.1.10
Using coderay 1.1.0
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using sass 3.4.13
Using bootstrap-sass 3.3.4.1
Using columnize 0.9.0
Using byebug 4.0.5
Using carrierwave 0.10.0
Using coffee-script-source 1.9.1.1
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.1
Using coffee-rails 4.1.0
Using orm_adapter 0.5.0
Using responders 2.1.0
Using warden 1.2.3
Using devise 3.4.1
Using excon 0.45.3
Using faker 1.4.3
Using figaro 1.1.0
Using fission 0.5.0
Using formatador 0.2.5
Using net-ssh 2.9.2
Using net-scp 1.2.1
Using fog-core 1.30.0
Using fog-xml 0.1.2
Using fog-atmos 0.1.0
Using multi_json 1.11.0
Using fog-json 1.0.1
Using ipaddress 0.8.0
Using fog-aws 0.1.2
Using inflecto 0.0.2
Using fog-brightbox 0.7.1
Using fog-ecloud 0.1.1
Using fog-local 0.2.1
Using fog-powerdns 0.1.1
Using fog-profitbricks 0.0.2
Using fog-radosgw 0.0.4
Using fog-riakcs 0.1.0
Using fog-sakuracloud 1.0.1
Using fog-serverlove 0.1.2
Using fog-softlayer 0.4.5
Using fog-storm_on_demand 0.1.1
Using fog-terremark 0.1.0
Using fog-vmfusion 0.1.0
Using fog-voxel 0.1.0
Using fog 1.29.0
Using jbuilder 2.2.13
Using jquery-rails 4.0.3
Using method_source 0.8.2
Using mini_magick 4.2.3

Errno::EACCES: Permission denied @ rb_sysopen - /Users/jonathanmusso/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/pg-0.18.1/.gemtest
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.

~/code/Bloccit  master ✔                                                                                                                                              2d  ⍉
▶ gem install pg -v '0.18.1'
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Users/jonathanmusso/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/pg-0.18.1/.gemtest

编辑:使用gemfile更新。

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
group :production do
  gem 'pg'
  gem 'rails_12factor'
end

group :development do
  gem 'binding_of_caller'
  gem 'better_errors'
  gem 'sqlite3'
end

# Use will_paginate
gem 'will_paginate', '~> 3.0.5'

# Use Fog
gem 'fog'

# Use CarrierWave and MiniMagick
gem 'carrierwave'
gem 'mini_magick'

# Use Redcarpet
gem 'redcarpet'

# Use Pundit
gem 'pundit'

# Use Figaro
gem 'figaro'

# Use Devise
gem 'devise'

# Use Bootstrap-Sass Gem
gem 'bootstrap-sass'

# Use pry-rails
gem 'pry-rails'

# Faker gem
gem 'faker'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

4 个答案:

答案 0 :(得分:2)

您最近更新了OSX吗?也许你需要更新你的xcode / xcode工具,然后重新安装postgres。

你有自制的postgres吗?如果是,请尝试重新安装正在运行的

  

brew uninstall postgresql

然后

  

brew install postgresql

然后,再次尝试运行“bundle install”。

答案 1 :(得分:1)

将“pg”gem添加到您的gem文件中,而不是在终端中手动安装它并运行“bundle install”。 在gemfile中添加: `gem'pg'

答案 2 :(得分:1)

一个稍微不那么沉重的penner答案版本,我遇到了同样的问题,经过一番挖掘后发现pg-0.18.1中的lib/ruby/gems/2.2.0/gems/目录由root拥有(可能是由于误用{ {1}}正如他所指出的那样)。我sudo编辑了该目录(以及rm -rf清除了extensions之后安装失败的目录,然后安装有效。

简短回答:gems沿着错误提供给你的那条长路径走下去,当你找到root拥有的任何目录时,摆脱它们。

答案 3 :(得分:0)

可能很重视

chown -R jonathanmusso:staff /Users/jonathanmusso/.rvm

如果你在rvm中使用了sudo,那么你可能已经破坏了安装。尝试更新rvm。