繁体   English   中英

pg gem的Rails和bundle安装错误?

[英]Rails s and bundle install error with pg gem?

我正在尝试为我的学校程序在运行Yosemite 10.10的MacBook Pro上安装Ruby on Rails。 我已经成功安装了所有组件,但是现在当我运行rails时,出现了此错误。 我试图继续安装捆绑软件以解决该问题,但是如您所见,它不起作用。 这里发生了什么? 我继续尝试使用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

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

您是否通过自制软件安装了postgres? 如果是,请尝试重新安装运行

brew卸载postgresql

接着

brew安装postgresql

然后,再次尝试运行“捆绑安装”。

将“ pg” gem添加到您的gemfile中,而不是在终端中手动安装它,然后运行“捆绑安装”。 将此添加到您的gemfile中:`gem'pg'

Penner答案的手语版本稍轻一些,我遇到了同样的问题,经过一番挖掘发现, lib/ruby/gems/2.2.0/gems/中的pg-0.18.1目录归root所有(可能是由于他指出,错误地使用了sudo )。 rm -rf ed该目录(以及一个extensions ,在清理完gems后, extensions使安装失败),然后安装成功。

简短答案: ls -la沿着错误的路径返回错误,当您找到root拥有的任何目录时,将其删除。

可能会用力

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

如果您将sudo与rvm一起使用,则可能会破坏安装。 尝试更新rvm。

暂无
暂无

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

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