Rails s 和 bundle 安装错误与 pg gem?
Rails s and bundle install error with pg gem?
我正在尝试在我的 MacBook Pro 运行ning Yosemite 10.10 上的 Rails 上安装 Ruby 用于我的学校程序。我已经成功安装了所有东西,但是现在当我 运行 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
将 'pg' gem 添加到您的 gem 文件中,而不是在您的终端和 运行 'bundle install' 中手动安装它。
将此添加到您的 gem 文件中:
`gem'pg'
您最近更新了 OSX 了吗?也许您需要更新 xcode/xcode 工具,然后重新安装 postgres。
你用自制软件安装过postgres吗?如果是,请尝试重新安装运行ning
brew uninstall postgresql
然后
brew install postgresql
然后,再试一次 运行 "bundle install"。
可能手头重
chown -R jonathanmusso:staff /Users/jonathanmusso/.rvm
如果您将 sudo 与 rvm 一起使用,您可能会破坏安装。尝试更新 rvm。
penner's answer 的一个稍微不那么严厉的版本,我遇到了同样的问题,经过一些挖掘发现 lib/ruby/gems/2.2.0/gems/
中的 pg-0.18.1
目录归 root 所有(可能是由于错误使用sudo
正如他所说)。我 rm -rf
编辑了那个目录(还有一个 extensions
在 gems
目录被清理后安装失败的目录)然后安装成功了。
简短回答:ls -la
沿着错误给你的那条长路走下去,当你找到 root 拥有的任何目录时,摆脱它们。
我正在尝试在我的 MacBook Pro 运行ning Yosemite 10.10 上的 Rails 上安装 Ruby 用于我的学校程序。我已经成功安装了所有东西,但是现在当我 运行 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
将 'pg' gem 添加到您的 gem 文件中,而不是在您的终端和 运行 'bundle install' 中手动安装它。 将此添加到您的 gem 文件中: `gem'pg'
您最近更新了 OSX 了吗?也许您需要更新 xcode/xcode 工具,然后重新安装 postgres。
你用自制软件安装过postgres吗?如果是,请尝试重新安装运行ning
brew uninstall postgresql
然后
brew install postgresql
然后,再试一次 运行 "bundle install"。
可能手头重
chown -R jonathanmusso:staff /Users/jonathanmusso/.rvm
如果您将 sudo 与 rvm 一起使用,您可能会破坏安装。尝试更新 rvm。
penner's answer 的一个稍微不那么严厉的版本,我遇到了同样的问题,经过一些挖掘发现 lib/ruby/gems/2.2.0/gems/
中的 pg-0.18.1
目录归 root 所有(可能是由于错误使用sudo
正如他所说)。我 rm -rf
编辑了那个目录(还有一个 extensions
在 gems
目录被清理后安装失败的目录)然后安装成功了。
简短回答:ls -la
沿着错误给你的那条长路走下去,当你找到 root 拥有的任何目录时,摆脱它们。