2017-03-29 30 views
7

尝试当我尽管使用束EXEC前缀得到这个错误执行在Windows上的cygwin上(x64)的化身。束EXEC - 您已经激活了JSON X,但是你的Gemfile需要JSONŸ

不应该在执行时激活Gemfile中定义的依赖项(即1.8.6)吗?

对这里出了什么问题有任何想法?我对Ruby宝石的世界是全新的。我看了其他“你已经激活..”帖子显示类似的消息,但那里的答案没有解决我的问题。

$捆绑高管化身成为

$ bundle exec jekyll serve 
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:40:in 
`block in setup': You have already activated json 2.0.2, but your Gemfile requires json 1.8.6. 
Prepending `bundle exec` to your command may solve this. (Gem::LoadError) 

环境在Cygwin

0123安装

    安装在Windows 7
  • Cygwin的x86_64的
  • RVM
    $ rvm -v 
    rvm 1.29.0 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/] 
    
    $ ruby -v 
    ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-cygwin] 
    

的Gemfile - 为哲基尔项目

source 'https://rubygems.org' 

require 'json' 
require 'open-uri' 
versions = JSON.parse(open('https://pages.github.com/versions.json').read) 

gem 'github-pages', group: :jekyll_plugins 
gem 'json', '~> 1.8.0' 

$宝石环境

$ gem environment 
RubyGems Environment: 
    - RUBYGEMS VERSION: 2.6.10 
    - RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-cygwin] 
    - INSTALLATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0 
    - USER INSTALLATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.gem/ruby/2.4.0 
    - RUBY EXECUTABLE: /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/bin/ruby.exe 
    - EXECUTABLE DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/bin 
    - SPEC CACHE DIRECTORY: /cygdrive/c/Users/mochapenguin/.gem/specs 
    - SYSTEM CONFIGURATION DIRECTORY: /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/etc 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86_64-cygwin 
    - GEM PATHS: 
    - /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0 
    - /cygdrive/c/Users/mochapenguin/.rvm/gems/[email protected] 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - REMOTE SOURCES: 
    - https://rubygems.org/ 
    - SHELL PATH: 
    - /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/bin 
    - /cygdrive/c/Users/mochapenguin/.rvm/gems/[email protected]/bin 
    - /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/bin 
    - /usr/local/bin 
    - /usr/bin 
    - /cygdrive/c/Windows/system32 
    - /cygdrive/c/Windows 
    - /cygdrive/c/Windows/System32/Wbem 
    - /cygdrive/c/Windows/System32/WindowsPowerShell/v1.0 
    - /cygdrive/c/Program Files/Java/jdk1.8.0_121/bin 
    ..... snip ..... 
    - /cygdrive/c/Users/mochapenguin/AppData/Local/atom/bin 
    - /usr/lib/lapack 
    - /cygdrive/c/Users/mochapenguin/.rvm/bin 

包更新

$ bundle update 
Fetching gem metadata from https://rubygems.org/........... 
Fetching version metadata from https://rubygems.org/.. 
Fetching dependency metadata from https://rubygems.org/. 
Resolving dependencies... 
Using i18n 0.8.1 
Using json 1.8.6 
Using minitest 5.10.1 
Using thread_safe 0.3.6 
Using public_suffix 2.0.5 
Using coffee-script-source 1.12.2 
Using execjs 2.7.0 
Using colorator 1.1.0 
Using ffi 1.9.18 
Using multipart-post 2.0.0 
Using forwardable-extended 2.6.0 
Using gemoji 3.0.0 
Using net-dns 0.8.0 
Using sass 3.4.23 
Using rb-fsevent 0.9.8 
Using kramdown 1.13.2 
Using liquid 3.0.6 
Using mercenary 0.3.6 
Using rouge 1.11.1 
Using safe_yaml 1.0.4 
Using mini_portile2 2.1.0 
Using jekyll-paginate 1.1.0 
Using jekyll-swiss 0.4.0 
Using minima 2.0.0 
Using unicode-display_width 1.1.3 
Using bundler 1.14.6 
Using tzinfo 1.2.3 
Using addressable 2.5.0 
Using coffee-script 2.4.1 
Using ethon 0.10.1 
Using rb-inotify 0.9.8 
Using faraday 0.11.0 
Using pathutil 0.14.0 
Using jekyll-sass-converter 1.5.0 
Using nokogiri 1.7.1 
Using terminal-table 1.7.3 
Using activesupport 4.2.7 
Using jekyll-coffeescript 1.0.1 
Using typhoeus 0.8.0 
Using listen 3.0.6 
Using sawyer 0.8.1 
Using html-pipeline 2.5.0 
Using jekyll-watch 1.5.0 
Using octokit 4.6.2 
Using jekyll 3.4.3 
Using github-pages-health-check 1.3.3 
Using jekyll-gist 1.4.0 
Using jekyll-avatar 0.4.2 
Using jekyll-default-layout 0.1.4 
Using jekyll-feed 0.9.2 
Using jekyll-github-metadata 2.3.1 
Using jekyll-mentions 1.2.0 
Using jekyll-optional-front-matter 0.1.2 
Using jekyll-readme-index 0.1.0 
Using jekyll-redirect-from 0.12.1 
Using jekyll-relative-links 0.4.0 
Using jekyll-seo-tag 2.1.0 
Using jekyll-sitemap 1.0.0 
Using jekyll-theme-architect 0.0.3 
Using jekyll-theme-cayman 0.0.3 
Using jekyll-theme-dinky 0.0.3 
Using jekyll-theme-hacker 0.0.3 
Using jekyll-theme-leap-day 0.0.3 
Using jekyll-theme-merlot 0.0.3 
Using jekyll-theme-midnight 0.0.3 
Using jekyll-theme-minimal 0.0.3 
Using jekyll-theme-modernist 0.0.3 
Using jekyll-theme-primer 0.1.7 
Using jekyll-theme-slate 0.0.3 
Using jekyll-theme-tactile 0.0.3 
Using jekyll-theme-time-machine 0.0.3 
Using jekyll-titles-from-headings 0.1.5 
Using jemoji 0.8.0 
Using github-pages 132 
Bundle updated! 

束EXEC - 完整的错误消息

$ bundle exec jekyll serve 
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:40:in `block in setup': You have already activated json 2.0.2, but your Gemfile requires json 1.8.6. Prepending `bundle exec` to your command may solve this. (Gem::LoadError) 
     from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `each' 
     from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `each' 
     from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:25:in `map' 
     from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:25:in `setup' 
     from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler.rb:100:in `setup' 
     from /cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.6/lib/bundler/setup.rb:10:in `<top (required)>' 
     from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
     from /cygdrive/c/Users/mochapenguin/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' 

JSON宝石

$ gem list json 

*** LOCAL GEMS *** 
json (default: 2.0.2, 1.8.6) 

束秀JSON

$ bundle show json 
/cygdrive/c/Users/mochapenguin/.rvm/gems/ruby-2.4.0/gems/json-1.8.6 

无法卸载一个defaul牛逼宝石

$ gem uninstall json -v2.0.2 
ERROR: While executing gem ... (Gem::InstallError) 
    gem "json" cannot be uninstalled because it is a default gem 

更新 - 12-APR-2017

我不知道是什么问题还在,但我修剪下来的Gemfile到这一点,它不会在堆下跌。当这些特定的版本依赖不被执行时,它可能会以某种方式起作用。

source 'https://rubygems.org' 

# sample suggested [here](https://jekyllrb.com/docs/github-pages/) and in github help 
gem 'github-pages', group: :jekyll_plugins 

更新 - 21-APR-2017

这个问题与捆绑和系统宝石高亮显示at Gem Versioning and Bundler - Doing it right

捆扎机的沙箱依靠其出席的非常能力开始的Ruby进程,因此有能力确保所有加载的库的版本将反映在Gemfile.lock中列出的版本。通过运行系统可执行文件,您可以在Bundler修改加载路径并替换普通的Rubygems加载机制之前执行Ruby代码,从而允许任意非托管的gem加载到内存中。 一旦发生这种情况,所有投注都将停止。

这就是在这种情况下似乎正在发生的事情。

但是,如上所述 - 无法卸载系统json 2.0.2 gem。

+0

你有没有找到解决办法? – meeDamian

+0

对不起队友。从4月12日我的更新是我得到的最好的。因为我只需要运行jekyll命令,所以我没有更进一步。我相信你也可以定义宝石套装。这可能是目前情况下的下一个最佳选择。 HTH。 – JetStream

回答

-4

我昨天有同样的问题。我不是专家,但对我来说,工作下列:

$ jekyll new "name_site" 

我再复制在新的文件夹到旧的新的Gemfile和Gemfile.lock的(:

我使用创造了杰基尔一个新的网站你有问题的地方)。然后,运行:

$ jekyll serve 
您目前的网站的文件夹中

,它应该工作。请让我知道这对你有没有用!

+0

我相信gem需要使用'bundle exec'来执行,以便绑定器gem启动。它的作用类似于正在执行的主要gem(即本例中的jekyll)的包装并应用Gemfile中定义的依赖关系。 – JetStream

1

有点迟到游戏,但嘿,我有一个解决方案!这就是我的做法:除了在宝石安装的标准地点寻找外,还有一个地方可以将宝石明确地“定义”并带入系统。我安装使用rbenv(我建议这种过度RVM)的东西,这些都是目录,对我来说:

/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems 
/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/specifications/default 

在你的情况,你的确切位置/ s的可能是不同的,但你应该能够弄清楚。如果宝石位于标准位置(/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems),那么您可以毫无问题地'宝石卸载'。对于另一个位置,虽然...艰难。为了简单地防止识别系统版本,以便您可以使用Gemfile中的版本,只需将json-X.gemspec文件从其他位置的第二个目录(/home/jf/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/specifications/default)移开即可。就是这样!

+0

哇,多么疯狂的修复......谢谢!我使用'ruby-install'和'chruby',并且对于我来说移动/删除的文件位于'〜/ .rubies/ruby​​-2.5.0/lib/ruby​​/gems/2.5.0/specifications/default/json- 2.1-0.gemspec'。这使我的包再次使用json-1.8.6 –

相关问题