As a macOS user, you might want to be warned against running bundler as root (specifically against the system ruby), because you can cause subsequent problems for installing future gems.
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
But what if this is deployment to a Linux machine and installing to the system ruby is your intent?
If you want to keep your logs clean of the warning message (especially if you have warnings highlighted), you can use one of the following options:
The following sets in ~/.bundle/config (/root/.bundle/config if root/sudo)
bundle config silence_root_warning true
The following can also be used if you want to temporarily disable the warning (a la “I know what I’m doing”)
export BUNDLE_SILENCE_ROOT_WARNING=true
As seen below using the bundle config option will fix sudo bundle install to not show the warning.
I forgot how much setup was required to go from a base Ubuntu install to bundling and running ruby things:
“mkmf.rb can’t find header files for ruby” and other header files messages with bundler… new to also install ruby-dev with your ruby package install in Ubuntu
On Ubuntu… need the following:
apt-get install -y ruby ruby-dev make gcc g++
Why would you need a command line time zone conversion?
Imagine that you’re troubleshooting a problem. Add that your team is distributed across multiple timezones. Now add that database times are generally recorded in UTC, but your alerting all displays in local time.
If you’re trying to pinpoint when an event happened and comparing notes across systems and observations, you’re going to be doing some time zone conversion to validate that all the observations are related to the same time period. That can be a bit tedious, especially if you’re already juggling a lot of details about the problem. For me, I wrote a quick script to be a time converter calculator to as a guide to help me align time stamps from different sources.
Parsing the time
Once require 'time' is added to the script, Time.parse(time_string) will work. But I also wanted to support if you had a date or time offset, such as 2022-04-20 11:09 -0500 without having to put the argument in quotes, so I joined the arguments:
# support calling as "convert_time 2022-04-20 11:09 -0500"
arg_time=ARGV.join(' ')
the_time=Time.parse(arg_time)
The resultant parsed time will be interpreted as a local time unless a time zone offset was specified.
Making things pretty
I’m using the colorize gem for coloring the output. Note: Windows Terminal or similar is required for full color output.
Converting timezones
(tzinfo-data gem is required for Windows or else you’ll end up with a TZInfo::DataSourceNotFound)
I’m using the tzinfo gem to convert times to specified times by grabbing a TZInfo::Timezone and calling to_local
I look through a hash of all of my “locations” (keys) and respective time zone representations (values) in time_zone_hash and present times for each as a time zone chart:
convert_times output on Windows Terminal
The Time Zone Conversion Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I just had this in a script to call when comparing timestamps, but it could be bundled and the hash itself could be in a configuration or yaml file to clean up the time zone conversion.
Leave a Reply