Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Correctly set loaded_from when use installed gem
Browse files Browse the repository at this point in the history
In bundler 1.16.0, the following script using `bundler/inline` fails.

```ruby
require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", github: "rails/rails"
  gem "arel", github: "rails/arel"
end
```

```
$ ruby script.rb
(snip)

.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:28:in `block in setup': rake-12.2.1 is missing. Run `bundle install` to get it. (Bundler::GemNotFound)
	from .rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each'
	from .rbenv/versions/2.4.1/lib/ruby/2.4.0/forwardable.rb:229:in `each'
	from .rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:26:in `map'
	from .rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:26:in `setup'
	from .rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/inline.rb:70:in `gemfile'
	from script.rb:3:in `<main>'
```

When gem has already been installed, it seems that `loaded_from` is not
set correctly, so set it up.
  • Loading branch information
y-yagi committed Nov 14, 2017
1 parent 914a4a8 commit ef123ce
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def install(spec, opts = {})
end

if installed?(spec) && !force
spec.loaded_from ||= loaded_from(spec)

print_using_message "Using #{version_message(spec)}"
return nil # no post-install message
end
Expand Down

0 comments on commit ef123ce

Please sign in to comment.