由于json gem错误不能运行Rails服务器?

时间:2021-09-22 00:15:03

I get an error while trying to run the rails server. Seems like I can't install the json gem properly. When I first tried to install the gems, I got the 1.8.2 version of the json gem. For some reason I got the same error messages as attached when I tried to run the server. In order to install the 1.7.7 version of json, I have uninstalled the 1.8.2 gem.

我在运行rails服务器时出错。看起来我无法正确安装json gem。当我第一次尝试安装gem时,我得到了1.8.2版本的json gem。出于某种原因,当我试图运行服务器时,我得到了与附件相同的错误消息。为了安装1.7.7版本的json,我已经卸载了1.8.2 gem。

Does anyone know how to fix this problem? Thank you in advance:)

有人知道怎么解决这个问题吗?提前谢谢你:)

$ rails s
Could not find json-1.7.7 in any of the sources
Run `bundle install` to install missing gems.

$ 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.0.3
[...]
Using rack-ssl 1.3.3

Errno::EACCES: Permission denied @ rb_sysopen - /Users/annemarit/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/json-1.7.7/.gitignore
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling.

$ gem install json -v '1.7.7'
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Users/annemarit/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/json-1.7.7/.gitignore

1 个解决方案

#1


0  

When permission is denied, this can sometimes mean that you installed the gem with sudo permission meaning that you have to have root access to install/update. This happened once to me where I was installing everything with root access since I was signed in as root and forgot.

当权限被拒绝时,这有时意味着您安装了具有sudo权限的gem,这意味着您必须有根访问来安装/更新。这一次发生在我身上,我在root权限下安装了所有的东西,因为我是root用户,并且忘记了。

The solution I found was to uninstall everything and reinstall as non sudo. It was a painful process, but it fixed my no permission error. If you continue as root and keep installing everything as sudo, you will run into major problems later as well, so never run in sudo when developing RoR applications.

我找到的解决方案是卸载所有的东西,然后重新安装。这是一个痛苦的过程,但它修正了我没有权限的错误。如果您继续作为root用户,并继续安装sudo,那么稍后您将遇到主要问题,所以在开发RoR应用程序时,不要在sudo中运行。

I hope this helps!

我希望这可以帮助!

#1


0  

When permission is denied, this can sometimes mean that you installed the gem with sudo permission meaning that you have to have root access to install/update. This happened once to me where I was installing everything with root access since I was signed in as root and forgot.

当权限被拒绝时,这有时意味着您安装了具有sudo权限的gem,这意味着您必须有根访问来安装/更新。这一次发生在我身上,我在root权限下安装了所有的东西,因为我是root用户,并且忘记了。

The solution I found was to uninstall everything and reinstall as non sudo. It was a painful process, but it fixed my no permission error. If you continue as root and keep installing everything as sudo, you will run into major problems later as well, so never run in sudo when developing RoR applications.

我找到的解决方案是卸载所有的东西,然后重新安装。这是一个痛苦的过程,但它修正了我没有权限的错误。如果您继续作为root用户,并继续安装sudo,那么稍后您将遇到主要问题,所以在开发RoR应用程序时,不要在sudo中运行。

I hope this helps!

我希望这可以帮助!