简体   繁体   English

错误:尝试在我的rails应用程序中安装gem pg时,权限被拒绝@ rb_sysopen(Windows 7)

[英]Error: Permission Denied @ rb_sysopen when trying to install gem pg in my rails app (Windows 7)

Using windows 7 ultimate and running cmd as administrator. 使用Windows 7终极和运行cmd作为管理员。
I have recently started working with ruby on rails and in my new rails app I'm attempting to install postgres(pg) gem and then I get a permission denied error as shown below: 我最近开始使用ruby on rails和我的新rails应用程序,我正在尝试安装postgres(pg)gem,然后我得到一个权限被拒绝错误,如下所示:

C:\wamp\www\RailsApp>bundle install
DL is deprecated, please use Fiddle
Fetching gem metadata from https://rubygems.org/...........
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.8
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.8
Using rack 1.5.2
Using rack-test 0.6.3
Using actionpack 4.1.8
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.1.8
Using activemodel 4.1.8
Using arel 5.0.1.20140414130214
Using activerecord 4.1.8
Using coffee-script-source 1.8.0
Using execjs 2.2.2
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.8
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.2.6
Using jquery-rails 3.1.2

Errno::EACCES: Permission denied @ rb_sysopen - C:/Ruby21/lib/ruby/gems/2.1.0/ge
ms/pg-0.18.1-x86-mingw32/lib/2.1/pg_ext.so
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.

I have tried 我试过了

gem install pg

which leads to the same error. 这会导致同样的错误。
However... when I try 但是......当我尝试的时候

gem install pg -mingw32

It appears successfull: 它看起来很成功:

C:\wamp\www\RailsApp>gem install pg -mingw32
Fetching: pg-0.18.1-x86-mingw32.gem (100%)
Successfully installed pg-0.18.1-x86-mingw32
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.1-x86-mingw32
Installing ri documentation for pg-0.18.1-x86-mingw32
Done installing documentation for pg after 16 seconds
1 gem installed

Though after searching through several posts I fail to find a solution to how I can implement this with the gemfile to make the bundler run without errors nor find a solution to why I get the permission denied error in the first place. 虽然在搜索了几篇帖子之后我找不到解决方法,我可以用gemfile来实现这个,使bundle工作没有错误运行,也找不到解决方案,为什么我首先得到权限被拒绝错误。
Here is my current gemfile: 这是我当前的gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/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

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

Note: I have tried using 注意:我尝试过使用

gem 'pg', platform: :mingw

yet, the error still occurs. 然而,错误仍然发生。
Hope this helps as to make my problem clear and feel free to ask and I'll supply more data possible. 希望这有助于使我的问题清晰并随意提出,我将提供更多可能的数据。
Any suggestions are valued and accepted, thank you. 任何建议都被重视和接受,谢谢。

It looks like bundle is trying to install things in the 看起来bundle正试图安装东西

C:/Ruby21/lib/ruby/gems/2.1.0/ge
ms/pg-0.18.1-x86-mingw32/lib/2.1/

directory and your user (or the process that is executing bundle) does not have permission to write things to that particular directory. 目录和您的用户(或正在执行bundle的进程)没有permission将事物写入该特定目录。

I am no expert on bundle, but one troubleshooting step you could try is to run a windows command prompt as administrator explicitly. 我不是捆绑专家,但您可以尝试的一个故障排除步骤是明确地以管理员身份运行Windows命令提示符。 You can do this by searching for CMD , then right-clicking on it and selecting "run as administrator" . 您可以通过搜索CMD ,然后右键单击它并选择"run as administrator" This sometimes corrects file permissions issues when installing things in windows. 这有时会在Windows中安装时纠正文件权限问题。

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

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