Ruby on Rails / ChiliProject encoding issues

This week I’ve decided to exchange Redmine for the ChiliProject. The reason for this is the support for Ruby 1.9. My Apache Passenger server runs Ruby 1.9 so for Redmine I needed a seperate webserver.

When I tried to access the “My Account” page I recieved the following error:

ArgumentError (invalid byte sequence in US-ASCII):
  <internal:prelude>:10:in `synchronize'
  passenger (3.0.7) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.7) ...
`handle_spawn_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.7) helper-scripts/passenger-spawn-server:99:in `<main>'

Rendering /data/www/rails/chili/public/500.html (500 Internal Server Error)

Solution

How should I solve this? The chiliproject has an issue related to this: https://www.chiliproject.org/issues/591.

The following Apache configuration fixed the issue: (The sample is on a FreeBSD system)

I added the following code to a file in the /usr/local/apache22/envvars.d/environment.env

export LC_CTYPE="en_US.UTF-8"

Problems I ruled out or fixed

While trying I also made sure the following things were configured:

I made sure the database is UTF-8. I re-created the database
an ran the migrations again.

create database chiliproject character set utf8;

I used the mysql2 connector instead of the mysql connector in database.yml

Share

Running Ruby on Rails 3.1 on FreeBSD

Are you trying to install / run Rails 3.1 on a FreeBSD system…?
You will probably get errors of a missing javascript engine.

You should try to install node and google V8 as javascript engine

cd /usr/ports/lang/v8
make install clean
cd /usr/ports/www/node
make install clean

Now it should work :-)

Share

Freebsd – Broken Ruby Installation After Update

Yesterday I did a Ruby update of my Freebsd ports.
It mentioned Ruby needed to be updated. I always thinks this is Scary because I have several sites depending on the my Ruby installation.
You need to update once in a while, so I just upgraded it…

portupgrade -bapi

Today I saw my mysql-backup-cron Ruby script gave the following error:

mysql_backup.rb:3:in `require': no such file to load -- rubygems (LoadError)
	from mysql_backup.rb:3:in `<main>

WTF. I tried to run a rake task of my Rails apps.. The same error…

The gems still seem work. The command below nicely showed my Gems.

gem list 

After trying to reinstall the rubygems port which didn’t do a thing.
I found the solution was to REINSTALL RUBY completely.

cd /usr/lang/ruby18
make 
make deinstall
make install clean

BTW. My Rails apps were not affected because they run in an RVM environment …

Share

Freebsd Ports – Environmental variables

I’m a big fan of the FreeBSD port system. But the last few weeks
I had problems updating my freebsd ports.

A growing number of ports were giving the following error: “cc: /sbin:/bin:/…:/root/bin: No such file or directory”

A full sample:

libtool: link: cc -shared  .libs/lqr_gradient.o .libs/lqr_rwindow.o .libs/lqr_energy.o .libs/lqr_cursor.o .libs/lqr_carver.o .libs/lqr_carver_list.o .libs/lqr_carver_bias.o .libs/lqr_carver_rigmask.o .libs/lqr_vmap.o .libs/lqr_vmap_list.o .libs/lqr_progress.o   -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib /usr/local/lib/libglib-2.0.so /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin /usr/local/lib/libintl.so /usr/local/lib/libiconv.so /usr/local/lib/libpcre.so -lm    -Wl,-soname -Wl,liblqr-1.so.3 -o .libs/liblqr-1.so.3
cc: /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin: No such file or directory
gmake[2]: *** [liblqr-1.la] Error 1
gmake[2]: Leaving directory `/usr/ports/graphics/liblqr-1/work/liblqr-1-0.4.1/lqr'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/graphics/liblqr-1/work/liblqr-1-0.4.1'
gmake: *** [all] Error 2
*** Error code 1

After a lof of debugging and digging deeply in the /work directories of the broken ports. I found out
that libtool was generating a ‘wrong’ cc command. The part -L /sbin:/bin/usr/bin … etc was wrong. The path seperator ‘:’ should not be used. I thought libtool was broken. (Rule X pragmatic programmer: “SELECT Isn’t broken” ;-) )

After dinging deeply in this script I saw the $path variable was placed in this command…

After typing ‘set’ to see all environment variables I found out I defined a custom $path variable.
Probably by a typing mistake. Because the real environment variable for path is PATH (uppercase…)

After remove this variable ‘path’ (“unset path” in bash), all my problems were gone…. Yess !

So some words of wisdom: NEVER define an environment variable ‘path’ on freebsd !! (And be VERY careful with your other environment variables!)

Share

PHP Extension order and Core Dumps

After updating my FreeBSD port php and apache I suddenly got a whole lot of core dumps. The hosted websites were running fine, but the core dumps didn’t feel quite right.. (of course).

Another FreeBSD server of mine, also updated to the same version, didn’t have these core dumps.

Doing some research on the web I found that a wrong order in extensions.ini could be a cause of my problems.
Changing the order of the extensions.ini solved my problem!

The following extensions.ini is is working for me:


extension=fileinfo.so
extension=filter.so
extension=json.so
extension=zip.so
extension=hash.so
extension=pdf.so
extension=pgsql.so
extension=ctype.so
extension=mysql.so
extension=mbstring.so
extension=gettext.so
extension=dba.so
extension=sysvshm.so
extension=gmp.so
extension=pdo.so
extension=tidy.so
extension=pcntl.so
extension=openssl.so
extension=readline.so
extension=simplexml.so
extension=calendar.so
extension=posix.so
extension=tokenizer.so
extension=bz2.so
extension=dbase.so
extension=xmlwriter.so
extension=ldap.so
extension=session.so
extension=sybase_ct.so
extension=exif.so
extension=sysvmsg.so
extension=mcrypt.so
extension=bcmath.so
extension=pdo_sqlite.so
extension=mssql.so
extension=sockets.so
extension=zlib.so
extension=pcre.so
extension=curl.so
extension=mhash.so
extension=imap.so
extension=iconv.so
extension=spl.so
extension=dom.so
extension=pspell.so
extension=soap.so
extension=xmlreader.so
extension=shmop.so
extension=sqlite.so
extension=xml.so
extension=xsl.so
extension=mysqli.so
extension=wddx.so
extension=sysvsem.so
extension=ftp.so
extension=xmlrpc.so
extension=snmp.so
extension=ncurses.so
extension=odbc.so
extension=ming.so
extension=gd.so

Share