代码之家  ›  专栏  ›  技术社区  ›  Howard

在使用最新Ruby(2.4.1)+Rails的新机器上捆绑一年前的Rails应用程序时出错

  •  0
  • Howard  · 技术社区  · 7 年前

    我刚刚试着恢复我的一个旧Rails应用程序,创建于2016年7月。

    在我的新机器上捆绑新安装的Ruby和Rails时,我出现了这个错误,因为 json 现在包含在rails中,不再需要在GEM文件中:

    An error occurred while installing json (1.8.3), and Bundler cannot continue. Make sure that gem install json -v '1.8.3'` succeeds before bundling.
    

    Unfortunately, an unexpected error occurred, and Bundler cannot continue. 捆绑安装时:

    The git source `git://github.com/flori/json.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
    The git source `git://github.com/capistrano/rbenv.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
    Fetching git://github.com/flori/json.git
    The git source `git://github.com/flori/json.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
    The git source `git://github.com/capistrano/rbenv.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
    --- ERROR REPORT TEMPLATE -------------------------------------------------------
    # Error Report
    
    ## Questions
    
    Please fill out answers to these questions, it'll help us figure out
    why things are going wrong.
    
    - **What did you do?**
    
      I ran the command `/home/howard/.rbenv/versions/2.4.1/bin/bundle install`
    
    - **What did you expect to happen?**
    
      I expected Bundler to...
    
    - **What happened instead?**
    
      Instead, what happened was...
    
    - **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**
    
      I tried...
    
    - **Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md?**
    
      ...
    
    ## Backtrace
    
    ```
    ArgumentError: Invalid source: nil
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/source_list.rb:107:in `source_list_for'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/source_list.rb:56:in `get'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/definition.rb:746:in `block in converge_locked_specs'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/definition.rb:743:in `converge_locked_specs'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/definition.rb:228:in `resolve'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/definition.rb:159:in `specs'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/definition.rb:147:in `resolve_remotely!'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/installer.rb:226:in `resolve_if_need'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/installer.rb:78:in `run'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/installer.rb:24:in `install'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli/install.rb:68:in `run'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:191:in `block in install'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/settings.rb:92:in `temporary'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:190:in `install'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:22:in `dispatch'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:13:in `start'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/exe/bundle:30:in `block in <top (required)>'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
      /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/exe/bundle:22:in `<top (required)>'
      /home/howard/.rbenv/versions/2.4.1/bin/bundle:22:in `load'
      /home/howard/.rbenv/versions/2.4.1/bin/bundle:22:in `<main>'
    ```
    
    ## Environment
    
    ```
    Bundler   1.15.3
    Rubygems  2.6.11
    Ruby      2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
    GEM_HOME  /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
    GEM_PATH  /home/howard/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0:/home/howard/.gem/ruby/2.4.0
    Git       2.7.4
    Platform  x86_64-linux
    OpenSSL   OpenSSL 1.0.2g  1 Mar 2016
    ```
    
    ## Bundler settings
    
    ```
    without
      Set for your local app (/home/howard/Downloads/telefon/code/.bundle/config): "development:test"
    ```
    
    ## Gemfile
    
    ### Gemfile
    
    ```ruby
    source 'https://rubygems.org'
    
    
    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
    gem 'rails', '4.2.6'
    # Use sqlite3 as the database for Active Record
    gem 'sqlite3'
    # 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
    
    gem 'capistrano', '~> 3.1.0'
    gem 'capistrano-bundler', '~> 1.1.2'
    gem 'capistrano-rails', '~> 1.1.1'
    gem 'json', github: 'flori/json', branch: 'v1.8'
    
    # Add this if you're using rbenv
    gem 'capistrano-rbenv', github: "capistrano/rbenv"
    
    gem "browser"
    
    # 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'
    end
    
    group :development do
      # 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
    ```
    
    ### Gemfile.lock
    
    ```
    GIT
      remote: git://github.com/capistrano/rbenv.git
      revision: e056efc0c361cc15b76ff961d6c5f65ed5e2c57e
      specs:
        capistrano-rbenv (2.0.4)
          capistrano (~> 3.1)
          sshkit (~> 1.3)
    
    GEM
      remote: https://rubygems.org/
      specs:'
        actionmailer (4.2.6)
          actionpack (= 4.2.6)
          actionview (= 4.2.6)
          activejob (= 4.2.6)
          mail (~> 2.5, >= 2.5.4)
          rails-dom-testing (~> 1.0, >= 1.0.5)
        actionpack (4.2.6)
          actionview (= 4.2.6)
          activesupport (= 4.2.6)
          rack (~> 1.6)
          rack-test (~> 0.6.2)
          rails-dom-testing (~> 1.0, >= 1.0.5)
          rails-html-sanitizer (~> 1.0, >= 1.0.2)
        actionview (4.2.6)
          activesupport (= 4.2.6)
          builder (~> 3.1)
          erubis (~> 2.7.0)
          rails-dom-testing (~> 1.0, >= 1.0.5)
          rails-html-sanitizer (~> 1.0, >= 1.0.2)
        activejob (4.2.6)
          activesupport (= 4.2.6)
          globalid (>= 0.3.0)
        activemodel (4.2.6)
          activesupport (= 4.2.6)
          builder (~> 3.1)
        activerecord (4.2.6)
          activemodel (= 4.2.6)
          activesupport (= 4.2.6)
          arel (~> 6.0)
        activesupport (4.2.6)
          i18n (~> 0.7)
          json (~> 1.7, >= 1.7.7)
          minitest (~> 5.1)
          thread_safe (~> 0.3, >= 0.3.4)
          tzinfo (~> 1.1)
        arel (6.0.3)
        binding_of_caller (0.7.2)
          debug_inspector (>= 0.0.1)
        browser (2.1.0)
        builder (3.2.2)
        byebug (9.0.5)
        capistrano (3.1.0)
          i18n
          rake (>= 10.0.0)
          sshkit (~> 1.3)
        capistrano-bundler (1.1.4)
          capistrano (~> 3.1)
          sshkit (~> 1.2)
        capistrano-rails (1.1.7)
          capistrano (~> 3.1)
          capistrano-bundler (~> 1.1)
        coffee-rails (4.1.1)
          coffee-script (>= 2.2.0)
          railties (>= 4.0.0, < 5.1.x)
        coffee-script (2.4.1)
          coffee-script-source
          execjs
        coffee-script-source (1.10.0)
        concurrent-ruby (1.0.2)
        debug_inspector (0.0.2)
        erubis (2.7.0)
        execjs (2.7.0)
        globalid (0.3.6)
          activesupport (>= 4.1.0)
        i18n (0.7.0)
        jbuilder (2.5.0)
          activesupport (>= 3.0.0, < 5.1)
          multi_json (~> 1.2)
        jquery-rails (4.1.1)
          rails-dom-testing (>= 1, < 3)
          railties (>= 4.2.0)
          thor (>= 0.14, < 2.0)
        loofah (2.0.3)
          nokogiri (>= 1.5.9)
        mail (2.6.4)
          mime-types (>= 1.16, < 4)
        mime-types (3.1)
          mime-types-data (~> 3.2015)
        mime-types-data (3.2016.0521)
        mini_portile2 (2.1.0)
        minitest (5.9.0)
        multi_json (1.12.1)
        net-scp (1.2.1)
          net-ssh (>= 2.6.5)
        net-ssh (3.1.1)
        nokogiri (1.6.8)
          mini_portile2 (~> 2.1.0)
          pkg-config (~> 1.1.7)
        pkg-config (1.1.7)
        rack (1.6.4)
        rack-test (0.6.3)
          rack (>= 1.0)
        rails (4.2.6)
          actionmailer (= 4.2.6)
          actionpack (= 4.2.6)
          actionview (= 4.2.6)
          activejob (= 4.2.6)
          activemodel (= 4.2.6)
          activerecord (= 4.2.6)
          activesupport (= 4.2.6)
          bundler (>= 1.3.0, < 2.0)
          railties (= 4.2.6)
          sprockets-rails
        rails-deprecated_sanitizer (1.0.3)
          activesupport (>= 4.2.0.alpha)
        rails-dom-testing (1.0.7)
          activesupport (>= 4.2.0.beta, < 5.0)
          nokogiri (~> 1.6.0)
          rails-deprecated_sanitizer (>= 1.0.1)
        rails-html-sanitizer (1.0.3)
          loofah (~> 2.0)
        railties (4.2.6)
          actionpack (= 4.2.6)
          activesupport (= 4.2.6)
          rake (>= 0.8.7)
          thor (>= 0.18.1, < 2.0)
        rake (11.2.2)
        rdoc (4.2.2)
          json (~> 1.4)
        sass (3.4.22)
        sass-rails (5.0.4)
          railties (>= 4.0.0, < 5.0)
          sass (~> 3.1)
          sprockets (>= 2.8, < 4.0)
          sprockets-rails (>= 2.0, < 4.0)
          tilt (>= 1.1, < 3)
        sdoc (0.4.1)
          json (~> 1.7, >= 1.7.7)
          rdoc (~> 4.0)
        spring (1.7.1)
        sprockets (3.6.0)
          concurrent-ruby (~> 1.0)
          rack (> 1, < 3)
        sprockets-rails (3.0.4)
          actionpack (>= 4.0)
          activesupport (>= 4.0)
          sprockets (>= 3.0.0)
        sqlite3 (1.3.11)
        sshkit (1.11.1)
          net-scp (>= 1.1.2)
          net-ssh (>= 2.8.0)
        thor (0.19.1)
        thread_safe (0.3.5)
        tilt (2.0.5)
        tzinfo (1.2.2)
          thread_safe (~> 0.1)
        uglifier (3.0.0)
          execjs (>= 0.3.0, < 3)
        web-console (2.3.0)
          activemodel (>= 4.0)
          binding_of_caller (>= 0.7.2)
          railties (>= 4.0)
          sprockets-rails (>= 2.0, < 4.0)
    
    PLATFORMS
      ruby
    
    DEPENDENCIES
      browser
      byebug
      capistrano (~> 3.1.0)
      capistrano-bundler (~> 1.1.2)
      capistrano-rails (~> 1.1.1)
      capistrano-rbenv!
      coffee-rails (~> 4.1.0)
      jbuilder (~> 2.0)
      jquery-rails
      rails (= 4.2.6)
      sass-rails (~> 5.0)
      sdoc (~> 0.4.0)
      spring
      sqlite3
      uglifier (>= 1.3.0)
      web-console (~> 2.0)
    
    BUNDLED WITH
       1.12.5
    ```
    
    --- TEMPLATE END ----------------------------------------------------------------
    
    Unfortunately, an unexpected error occurred, and Bundler cannot continue.
    
    First, try this link to see if there are any existing issue reports for this error:
    https://github.com/bundler/bundler/search?q=Invalid+source++nil&type=Issues
    
    If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
    https://github.com/bundler/bundler/issues/new
    

    有人知道我能从这种情况中得到什么吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   m. simon borg    7 年前

    如果你需要移除宝石,你应该从你的 Gemfile Gemfile.lock

    Gemfile公司 : gem 'json', github: 'flori/json', branch: 'v1.8'

    bundler 创建 Gemfile.lock 在解决您的依赖关系后 bundle install ,基于您的 Gemfile.lock 还指定不在您的 Gemfile公司 但这些都是宝石的依存关系。手动编辑几乎肯定会给你带来问题,什么都不修复。

    但您可能根本不需要删除它。现在你被锁定在 json 捆扎机 Gemfile.lock 然后让 生成一个全新的。