简体   繁体   English

Rails捆绑安装无法正常工作,原因是JSON版本错误

[英]Rails bundle install doesn't work 'cause json version error

I just wanted to convert from ImageMagick v7 to ImageMagick v6. 我只是想从ImageMagick v7转换为ImageMagick v6。 while doing that, this error was happened. 这样做时,发生了此错误。

bundle install doesn't work correctly. 捆绑安装无法正常工作。

It seems like json version is something wrong. 看来json版本有问题。

How do I fix this error? 如何解决此错误?

Environment below 下面的环境

  1. ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17] 红宝石2.3.1p112(2016-04-26修订版54768)[x86_64-darwin17]
  2. Rails -v (couldn't find gem) (becuase bundle install can't work) Rails -v(找不到gem)(因为捆绑安装无法工作)
  3. json list / json (default: 1.8.3) multi_json (1.13.1, 1.11.2, 1.11.0) json列表/ json(默认:1.8.3)multi_json(1.13.1,1.11.2,1.11.0)
  4. Bundler version 1.16.4 Bundler版本1.16.4
  5. Mac Mojave 10.14 Mac Mojave 10.14

when I do bundle install on terminal, then I got this error 当我在终端上捆绑安装时,出现此错误

Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......
Using rake 12.3.2
Using concurrent-ruby 1.1.4
Using i18n 0.9.5
Fetching json 1.8.6
Installing json 1.8.6 with native extensions
Errno::EPERM: Operation not permitted @ chmod_internal -
/Users/***/projects/***/vendor/bundle/ruby/2.3.0/gems/json-1.8.6/tests/test_json.rb
An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6' --source 
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
rails was resolved to 4.2.6, which depends on
actionmailer was resolved to 4.2.6, which depends on
  actionpack was resolved to 4.2.6, which depends on
    actionview was resolved to 4.2.6, which depends on
      rails-dom-testing was resolved to 1.0.9, which depends on
        rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
          activesupport was resolved to 4.2.6, which depends on
            json

I tried to do like this because error statement says Make sure that 我尝试这样做是因为错误声明说请确保
gem install json -v '1.8.6' --source 'https://rubygems.org/' succeeds before bundling gem install json -v '1.8.6' --source 'https://rubygems.org/'在绑定之前成功

but result shows like this 但是结果显示像这样

ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted @ chmod_internal - /Users/***/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/tests/test_json.rb

I can't understand this error statement 我不明白这个错误陈述

Errno::EPERM: Operation not permitted @ chmod_internal -

Also, I goggled a lot, then I update commandlinetool follow this https://howchoo.com/g/m2u0mmuwzda/macos-mojave-fix-invalid-active-developer-path 另外,我进行了很多眼神检查,然后按照以下https://howchoo.com/g/m2u0mmuwzda/macos-mojave-fix-invalid-active-developer-path的方式更新了命令行工具

then, I did this command again, 然后,我再次执行了此命令,

sudo gem install json -v '1.8.6' --source 'https://rubygems.org/'

then, it's completely succeded like this. 然后,它完全成功了。

Building native extensions. This could take a while...
Successfully installed json-1.8.6
Parsing documentation for json-1.8.6
Installing ri documentation for json-1.8.6
Done installing documentation for json after 1 seconds
1 gem installed

But, if I do bundle install, still doesn't work: they show same error. 但是,如果我捆绑安装,仍然无法正常工作:它们显示相同的错误。

My recommendation is if possible to start fresh. 我的建议是尽可能重新开始。 Maybe your rbenv was not installed correctly, try reinstalling it, I suggest using brew install rbenv https://github.com/rbenv/rbenv#homebrew-on-macos 也许您的rbenv未正确安装,请尝试重新安装它,建议您使用brew install rbenv https://github.com/rbenv/rbenv#homebrew-on-macos

Make sure to add the eval "$(rbenv init -)" to your ~/.bash_profile then open a new terminal. 确保将eval "$(rbenv init -)"到您的~/.bash_profile然后打开一个新终端。

Navigate to the project directory and install the Ruby version you need: rbenv install 2.3.1 导航到项目目录并安装所需的Ruby版本: rbenv install 2.3.1

You can make sure you are using that version by issuing rbenv use 2.3.1 and ruby --version . 您可以通过发出rbenv use 2.3.1ruby --version来确保使用该版本。

Now install bundler for that Ruby version, I suggest 1.17.3 for now (the latest before 2.0.1) gem install bundler -v '1.17.3' . 现在为该Ruby版本安装bundler,我建议现在使用1.17.3(2.0.1之前的最新版本) gem install bundler -v '1.17.3'

You should be ready to bundle install . 您应该已经准备好bundle install

The most common scenario I see for a message Installing ... with native extensions to result in errors is usually due to the lack of binaries, header files and C related code to build that native extension, in your case the issue is due to permissions, hence why I am suggesting some fresh installation. 我看到的最常见情况是,出现消息Installing ... with native extensions导致错误,通常是由于缺少二进制文件,头文件和与C有关的代码来构建该本机扩展,在这种情况下,问题是由于权限所致,因此为什么我建议重新安装。

I second @Danilo Cabello's recommendation to start fresh if you can. 如果可以的话,我赞同@Danilo Cabello的建议重新开始。 I just have a few other trouble-shooting ideas: 我还有其他一些疑难解答的想法:

The fact that your bundle is installing gems in /vendor/bundle means that at some point, you must have specified the path with bundle install --path vendor/bundle as @mogbee alludes to. 您的捆绑包正在/vendor/bundle安装gem的事实意味着,在某些时候,您必须已使用bundle install --path vendor/bundle指定了路径,因为@mogbee暗示了这一点。 That path flag will load files associated with your gems into vendor/bundle instead of your system gem location. 该路径标志会将与您的gem关联的文件加载到vendor/bundle而不是您的系统gem位置中。 You might have done that if you're trying to keep the project's gems separate from any other project, but if not, you will need to update your bundler's gem path. 如果试图将项目的gem与其他项目分开,则可能已经这样做了,但是如果不这样做,则需要更新捆绑程序的gem路径。

To do this, first, check for any issues by running bundle doctor . 为此,首先,通过运行bundle doctor检查任何问题。 If no issues are found, check your bundle configuration with bundle env . 如果未发现问题,请使用bundle env检查您的软件包配置。 Make sure that your RubyGems Gem Home and Gem Path are routed through .rbenv, so they should match and look like /Users/***/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0 . 确保您的RubyGems Gem Home和Gem Path通过.rbenv路由,因此它们应该匹配,并且看起来像/Users/***/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0 If they don't match, run the rbenv-doctor command below which should make sure your rbenv installation exported the path properly. 如果它们不匹配,请运行下面的rbenv-doctor命令,该命令应确保您的rbenv安装正确导出了路径。

If the output of bundle env tells you that you're actually running an older version of bundler (older than 1.16.4), I would definitely update, and would recommend version 1.17.3 as @Danilo Cabello did. 如果bundle env的输出告诉您您实际上正在运行的是旧版本的bundler(早于1.16.4),那么我肯定会进行更新,并建议使用@Danilo Cabello的1.17.3版本。

Second, I would run this rbenv-doctor curl command to check the status of your rbenv install: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash 其次,我将运行此rbenv-doctor curl命令来检查您的rbenv安装状态: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash ( https://github.com/rbenv/rbenv-installer#rbenv-doctor ). curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bashhttps://github.com/rbenv/rbenv-installer#rbenv-doctor )。

Third, depending on the output of ls -l within your project folder, you may also want to recursively change owner/group for your ~/.rbenv folder to make sure everything is owned by you and not root ( https://superuser.com/questions/260925/how-can-i-make-chown-work-recursively/260939#260939 ) 第三,根据项目文件夹中ls -l的输出,您可能还需要递归更改~/.rbenv文件夹的所有者/组,以确保所有内容都归您所有,而不是roothttps:// superuser。 com / questions / 260925 / how-can-i-make-chown-work-recursively / 260939#260939

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

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