Skip to content

Commit

Permalink
Remove unnecessary version guard from versions.rb
Browse files Browse the repository at this point in the history
Removing it triggers the following warnings when running `bundle` under
jruby from the root of the `psych` repo prints the following warnings:

```
/path/to/jruby-9.2.9.0/lib/ruby/gems/shared/gems/psych-3.1.0-java/lib/psych/versions.rb:7: warning: already initialized constant VERSION
/path/to//jruby-9.2.9.0/lib/ruby/gems/shared/gems/psych-3.1.0-java/lib/psych/versions.rb:10: warning: already initialized constant DEFAULT_SNAKEYAML_VERSION
```

This is because bundler loads the versions file relatively from the
local gemspec, and then internally loads the psych gem, causing the
redefinition warnings.

Instead, we modify the $LOAD_PATH so that when working locally on the
`psych` repo, the local version of `psych` gets used.
  • Loading branch information
deivid-rodriguez committed Feb 14, 2020
1 parent 8c56bff commit 6f8bbf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/psych/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true
module Psych
# The version of Psych you are using
VERSION = '3.1.0' unless defined?(::Psych::VERSION)
VERSION = '3.1.0'

if RUBY_ENGINE == 'jruby'
DEFAULT_SNAKEYAML_VERSION = '1.23'.freeze
Expand Down
10 changes: 4 additions & 6 deletions psych.gemspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

begin
require_relative 'lib/psych/versions'
rescue LoadError
# for Ruby core repository
require_relative 'versions'
end
lib_path = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift lib_path if File.exist?(lib_path)

require 'psych/versions'

Gem::Specification.new do |s|
s.name = "psych"
Expand Down

0 comments on commit 6f8bbf8

Please sign in to comment.