Ubuntu + Rmagick + Gem

 

If you run into trouble installing Rmagick on Ubuntu, it is most likely because you do not have the dev libraries installed that are needed by the rmagick Ruby Gem. Run the following commands in your terminal and everything should work fine.

sudo apt-get install graphicsmagick-libmagick-dev-compat
sudo apt-get install imagemagick
sudo apt-get install libmagickcore-dev
sudo apt-get install libmagickwand-dev
gem install rmagick

Ubuntu + RVM: Ruby Install – There was an error(23)

After a new install of RVM on Ubuntu, you may run into the error “There was an error(23)” in conjunction with a file write or folder creation permission error. This is caused when, for some reason, RVM does not properly add your Ubuntu user to the RVM group after it was installed. To correct this error, you need to complete the following steps, and executing the following commands:

Execute in terminal:
rvm group add rvm "$USER"

Log out of Ubuntu and log back in. If it still fails, you may need to have RVM fix its system permissions with the command:

Execute in terminal:
rvm fix-permissions

Rails 4: Set Application-Wide Date/DateTime/Time Display Format

If you are like me, you want the all dates and times to display throughout your application using the same format. This can be accomplished through the following procedure.

Create a new Rails ‘Initializer’ file in your application’s ‘/config/initializers’ directory titled ‘date_format.rb’ and then paste into that file the following Ruby script. Simply uncomment the format you wish to use for each of the types Date, DateTime, and Time.

# Date
# —————————-
#Date::DATE_FORMATS[:default] = “%Y-%m-%d” # 2013-11-03
#Date::DATE_FORMATS[:default] = “%B %e, %Y” # November 3, 2013
#Date::DATE_FORMATS[:default] = “%e %b %Y” # 3 Nov 2013
#Date::DATE_FORMATS[:default] = “%Y%m%d” # 20131103
#Date::DATE_FORMATS[:default] = “%e %b” # 3 Nov

# DateTime
# —————————-
#DateTime::DATE_FORMATS[:default] = “%Y-%m-%d” # 2013-11-03 14:22:18
#DateTime::DATE_FORMATS[:default] = “%B %e, %Y” # November 3, 2013 14:22
#DateTime::DATE_FORMATS[:default] = “%e %b %Y” # Sun, 3 Nov 2013 14:22:18 -0700
#DateTime::DATE_FORMATS[:default] = “%Y%m%d” # 20131103142218
#DateTime::DATE_FORMATS[:default] = “%e %b” # 3 Nov 14:22

# Time
# —————————-
#Time::DATE_FORMATS[:default] = “%Y-%m-%d %H:%M:%S” # 2013-11-03 14:22:18
#Time::DATE_FORMATS[:default] = “%B %d, %Y %H:%M” # November 3, 2013 14:22
#Time::DATE_FORMATS[:default] = “%a, %d %b %Y %H:%M:%S %z” # Sun, 3 Nov 2013 14:22:18 -0700
#Time::DATE_FORMATS[:default] = “%d %b %H:%M” # 3 Nov 14:22
#Time::DATE_FORMATS[:default] = “%Y%m%d%H%M%S” # 20131103142218
#Time::DATE_FORMATS[:default] = “%H:%M” # 14:22

Rails 4: gem install pg (when using the Postgresql App on OS X)

If you are getting a build error from Gem when trying to install the PostgreSQL gem called ‘pg’ and you are using the PostgreSQL App instead of installing PostgreSQL via Brew or some other method, it is because Gem cannot find the PostgreSQL config in the standard locations. To correct this you need to provide Gem with the path to the config file stored within the PostgreSQL App’s internal folder structure.

This can be done as follows:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config

Another way to accomplish this is:

export CONFIGURE_ARGS=”with-pg-include=/Applications/Postgres.app/Contents/Versions/9.4/include/”
gem install pg

Note: the latest version of the PostgreSQL App, at the time of this writing was 9.4, your version may be different. Make sure you change the 9.4 in the config path in the command above to the one you are using or it will not work. You can verify the path by opening Finder, going to the Applications folder, locating Postgres.app, right clicking and selecting ‘show package contents’. This will open up the app’s folder structure in Finder.

Mint 14: Latest Gedit Version + Ruby Plugins

If you are trying to use new plugins for Gedit, the default text editor on Mint, you might run into a problem as a lot of the new plugins require Gedit >=3.0 and be default Mint comes with 2.30.

To fix this you need to first get rid of Gedit 2.30 completely by running the following commands in your terminal.

sudo apt-get purge gedit
sudo apt-get purge gedit-common

Once those commands have completed successfully you need to run these commands to get the 3.6.1 version.





sudo apt-get install gedit-common/quantal
sudo apt-get install gedit/quantal

Now that we have the correct Gedit version we can install the Ruby and Rails plugins for Gedit. That’s all there is to it!

$ sudo apt-add-repository ppa:ubuntu-on-rails/ppa
$ sudo apt-get update
$ sudo apt-get install gedit-gmate

$ sudo apt-get install gedit-plugins

Ubuntu 12 : RVM : Default Gemset not Working/Setting

When setting up a Ruby/Rails development environment utilizing Ubuntu 12.04 LTS you may find yourself running into issues with setting your RVM default Gemset.

I attempted to set the default Gemset using every possible combination of the command rvm –default use 1.9.3-p286@corerivalry but every time I closed my terminal and re-opened it my default Ruby was set, but my Gemset was continually being set back to (default).
After much searching and frustration I ran into the –rvmrc command which creates a file (.rvmrc) that specifies the Ruby version as well as the Gemset to use for an individual project. After running the command, each time I opened my terminal in my Rail application’s root folder my Ruby and Gemset are exactly what I intend them to be.
The command:
rvm use 1.9.3-p286@rails3 --rvmrc

Ruby: Mint12 Sqlite3 Install Issues (sqlite3.h)

On the latest version of Linux Mint 12 (the Linux platform I prefer for Ruby development) I ran a bundle install on a small application using Sqlite3 and ran into the following error message. After a little Google search I found that my installing Sqlite3 did not give Gem all the build files it requires to build the Sqlite3-ruby gem with native extensions. So if you are running into the same issue make sure you run the following commands prior to running bundle install.

<<<>>>

sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev

<<<>>>

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/tim/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite-devel’ and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/home/tim/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
–with-sqlite3-dir
–without-sqlite3-dir
–with-sqlite3-include
–without-sqlite3-include=${sqlite3-dir}/include
–with-sqlite3-lib
–without-sqlite3-lib=${sqlite3-dir}/lib
–enable-local
–disable-local
Gem files will remain installed in /home/tim/.rvm/gems/ruby-1.9.2-p290@CorDev1.9.2/gems/sqlite3-1.3.6 for inspection.
Results logged to /home/tim/.rvm/gems/ruby-1.9.2-p290@CorDev1.9.2/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out