Bundler warning when running "bundle" - Ruby on Rails
Asked Answered
C

3

20

I installed ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16] versions using rbenv, and rails with the following version Rails 5.1.4

after creating a new app via rails new my-app

I am getting the followig error when I try to run bundle

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java. There was an error while trying to write to /Users/my-user/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions. It is likely that you need to grant write permissions for that path.```

Congo answered 14/10, 2017 at 1:59 Comment(0)
C
40

Just remove this line from your Gemfile

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

because you obviously do not run your application on any of these platforms.

Then run bundle install again.

Cruzeiro answered 14/10, 2017 at 5:31 Comment(7)
still getting this There was an error while trying to write to /Users/user/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions. It is likely that you need to grant write permissions for that path. Any ideas?Congo
I assume that /Users/user/... is your user's home directory. And yes, your user should be the owner of your bundler's cache directory.Cruzeiro
I am, meaning I have not done anything since installing rails. This default behavior.? Why would it prevent me from bundling?Congo
Did you install ruby or gem or bundler using sudo?Cruzeiro
Nope, that was not part of rails instructions - is that what’s needed?Congo
No, if you did you might have messed up your folders' ownership. Did you check what is wrong with that folder? Aren't you the owner or are you the owner but still do not have write access? Did you try to fix the folder's ownership?Cruzeiro
I'm running Rails 5.2.2 on Ubuntu 18.04 That line was sitting right at the end of my gem file - commented out. now works fine. # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]Barbarossa
B
8

Alternatively you can keep the tzinfo-data gem and just remove the platform part and it should become something like this:

gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data

Recently the RoR creator DHH has published Basecamp's most recent application's Gemfile for Hey! and it contains the line above.

Hope that can become useful for others as it was for me.

Bunco answered 4/7, 2020 at 18:30 Comment(0)
B
2

I had a similar challenge on my Ubuntu 20.04; ruby (2.7.1); rails (6.0.3.3):

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.

After running some searches, I found a fix on a git site page:

bundle config disable_platform_warnings true

I realized it wasn't an error but a time-zone dependency warning applicable to running rails application on Windows environment. Adding the disable_platform_warnings option for Bundler helps to silence platform warnings globally for the current machine.

You can read more at https://github.com/tzinfo/tzinfo-data/issues/12

Bernetta answered 27/9, 2020 at 18:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.