Rails 5: Array values in the parameter to `Gem.paths=` are deprecated
Asked Answered
G

3

36

Building websockets app based off of actioncable-examples. When starting server, running rake, etc. I keep getting the message:

Array values in the parameter to `Gem.paths=` are deprecated.

Haven't seen a solution here, but did find one. I wanted to post the question and answer here so that it's available.

Galang answered 16/6, 2016 at 15:57 Comment(0)
G
97

I found the answer in RubyGems issue #1551 here. The binstubs, the files in the bin folder, need to be updated. The best way to do this is:

bundle update spring
bundle exec spring binstub --remove --all
bundle exec spring binstub --all

And that resolved the problem for me.

Galang answered 16/6, 2016 at 16:0 Comment(0)
R
0

I also face same error in my rails 4.2.7 application and I fixed the error to update bin/spring file line no 11

Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
Rayshell answered 14/8, 2018 at 6:19 Comment(1)
This answer is useful because it points down to the root cause of the issue. However, the accepted answer above gives instructions to regenerate that same binstub file, which should be safer because there is no risk of putting the wrong code in by hand.Roundsman
M
-1

tl;dr bin/spring binstub, you might need to update spring before that (if 1.3.3 <= spring < 1.6.4).

spring had been using an array for the GEM_PATH value in its binstubs since 1.3.3 till 1.6.4.

In rubygems-2.6.0 they were planning to give up on arrays, but apparently those binstubs made its way in a lot of projects. So they restored the array handling in rubygems-2.6.1, but with a deprecation warning. Those 2 correspond to Ruby 2.4.0.

Mordred answered 25/1, 2021 at 0:22 Comment(3)
bundle update spring was the first command?Galang
@Galang Was? It is, if you're running 1.3.3 <= spring < 1.6.4. For spring >= 1.6.4 it is not required.Mordred
@Galang Actually I'm okay if you replace your answer with mine. Then I can delete mine. I'm just not sure if you agree.Mordred

© 2022 - 2024 — McMap. All rights reserved.