Problem w/ Paperclip, MacPorts, ImageMagick & Snow Leopard - ruby-on-rails-3

I'm attempting to use ImageMagick along w/ Paperclip to handle the images on my rails app. The problem is whenever I try to upload an image I get the following in the terminal:
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/go/goZ833AaFaqyvv5RnLqQmE+++TM/-Tmp-/stream20110107-6356-1xfs9j1-0.jpg is not recognized by the 'identify' command.>
I have added the following to my environments/development.rb file:
Paperclip.options[:command_path] = "/usr/local/bin"
If I try to interact w/ ImageMagick in the terminal by using "convert" or something similar I get:
dyld: Library not loaded: /opt/local/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/convert
Reason: Incompatible library version: convert requires version 10.0.0 or later, but libltdl.7.dylib provides version 9.0.0
Trace/BPT trap
I've already tried updating everything w/ port but the problem still persists. Does anyone have any ideas or suggestions?

I strongly suggest giving up macports and using homebrew. I've never once missed macports since changing. Homebrew uses git and ruby (tools you should be familiar with), and all the installation 'formulae' are very easy to follow. Here's the imagemagick one:
https://github.com/mxcl/homebrew/blob/master/Library/Formula/imagemagick.rb
Note that it spends a lot of time working around 'gotchas'. To install, you would just run:
brew install imagemagick

You appear have an older version of libtool. Running
"otool -LD /opt/local/lib/libltdl.7.dylib" should show you that. I had a similar issue, and solved it by uninstalling ImageMagick completely, then running
sudo port selfupdate
sudo port upgrade outdated (which upgraded libtool, btw)
and then reinstalling ImageMagick.

Just had the same issue, easily fixed it.
You may want to uninstall / reinstall the rmagick gem:
gem uninstall rmagick
gem install rmagick
Worked like a charm for me

Related

Shopify CLI seems unable to find Ruby on Mac

I installed shopify-cli using homebrew on my Mac and tried verifying the installation by running shopify version, but I get an error:
/usr/local/bin/shopify: line 2: /opt/homebrew/Cellar/ruby/3.0.1/bin/ruby: No such file or directory
Any idea what needs to be fixed?
Try running brew install ruby#3.0. It worked for me!
It appears that shopify-cli was installed when your Homebrew ruby was at version 3.0.1. This can be fixed by running the following command:
brew reinstall shopify-cli
(Ideally, the shopify-cli formula should be updated by its maintainers to replace hardcoded ruby paths to the version-agnostic /opt/homebrew/opt/ruby. Alternatively, they could track the Homebrew ruby version and bump the revision of shopify-cli whenever an update occurs. This will prompt end-users to run brew upgrade, which will automatically reinstall shopify-cli.)

Using lessc on Windows

I've been trying to work out how to install lesscss.org on Windows 7 so I can use it from a cygwin command line interface and also using Maven.
We have SASS running in this way but there is a requirement to use LESS in a new project.
My Steps so far...
Checked Ruby is installed, I have it installed at C:\Ruby193
Downloaded the Ruby DevKit and followed this to install it.
At CMD.exe, execute gem install less - 1 gem installed ... less-2.2.1
CMD.exe, run lessc - This gives [WARNING] Please install gem 'therubyracer' to use Less.
So at CMD.exe I try gem install therubyracer which gives this error...
ERROR:
Error installing therubyracer: ERROR: Failed to build gem native extension.
Full error is here
6. And this is where I'm stuck because lessc is still complaining therubyracer is not installed. I've also installed Python27 and added it to the Path variable as that came up in a previous error.
I can confirm I have this path C:\Ruby193\lib\ruby\gems\1.9.1\gems\therubyracer-0.10.1 which looks like a project to me but something is obviously wrong.
I've also found this as a potential answer to getting LESS on Windows but that would indicate we can't get the native 'real' version to run so both Macs, Windows and Ubuntu can use the same switches/ environment? github.com/duncansmart/less.js-windows
As the others mentioned, this is now easily done with node:
npm install -g less
This will install less as a global module that you can use from anywhere on the command line by typing:
lessc input-file.less output-file.css
An even easer way to do this is to just use a tool like SimpleLess that will automagically compile and minify your LESS for you:
http://wearekiss.com/simpless
Happy Coding!
Perhaps you had the same problem I did where you successfully installed the node module via:
npm install -g less
but when trying to run lessc, you were getting the error:
[WARNING] Please install gem 'therubyracer' to use Less.
I think this is because, though you've installed the node module, the lessc command is still tied to the ruby gem. Try uninstalling the less gem:
gem uninstall less
And then try running lessc again.

carrierwave + mini_magick gems = not an image error

I'm using:
- carrierwave 0.6.0
- rails 3.2.1
- mini_magick 3.4
- ruby 1.9.2p290
And during image uploading I want to resize uploading pic:
(image_uploader.rb)
process :resize_to_fit => [200, 200]
But after image uploading I've got an error:
1 error prohibited this organization from being saved:
Image image Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: MiniMagick::Invalid
PS. If I'm not resizing, image upload works fine.
PS2. I tried to add in config/environment.rb:
require 'rubygems'
require "mini_magick"
but without success (still not working - btw. is it required when using mini_magick as a gem?)
I'm sure that you've solved this by now (at least hopefully! It's almost two months later!), but here's a solution that worked for me just now:
Uninstall imagemagick through homebrew:
brew uninstall imagemagick
Clean your homebrew directory:
brew cleanup --force -s
--force removes all out of date keg-only brews, -s removes all cached downloads
Reinstall imagemagick:
brew install imagemagick
After all of that, you should be good to go!
B. Ruschill's answer seemed to have solved many peoples' problem, unfortunately it didn't for me. Nor did many solutions I found on the internets.
Turns out I had an outdated version of libjpeg. I fixed that by removing and re-installing using brew. This may happen for other image formats too. Perhaps doing the same for the respective libs might solve the problem.
TL;DR
brew remove libjpeg
brew install libjpeg

Anyone having issues installing bson_ext gem in OSX lion

OSX Lion, Xcode 4.2, GCC 4.2
I get the following error installing bson_ext 1.4.1
Building native extensions. This could take a while...
ERROR: Error installing bson_ext:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for asprintf()... *** 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.
I just ran into this. You should look in the mkmf.log file. Chances are, it's looking for GCC in the wrong place. I had to:
cd /usr/bin
sudo ln -s i686-apple-darwin11-llvm-gcc-4.2 i686-apple-darwin11-gcc-4.2.1
And all was well.
The accepted answer did not work for me. But this did.
I am using:
OS X 10.8.2
Xcode 4.6 (with command line tools)
bson_ext 1.8.2
cd /usr/bin && sudo ln -s ./gcc gcc-4.2
$ gem install bson_ext -v 1.8.2
Building native extensions. This could take a while...
Successfully installed bson_ext-1.8.2
1 gem installed
Installing ri documentation for bson_ext-1.8.2...
Installing RDoc documentation for bson_ext-1.8.2...
So re-installing OSX lion fixed the problem. I guess uninstalling xcode 4.1 in the first place messed up my developer tools installation.
Thanks for the help.
I don't use XCode for anything but the developer tool binaries so I just uninstalled XCode:
sudo /Developer/Library/uninstall-devtools –mode=all
And then installed this:
https://github.com/kennethreitz/osx-gcc-installer
Fixed the problem right up and I saved some HD space to boot.

RubyODBC Cannot allocate SQLHENV

I'm trying to connect to SQL Server on Ubuntu 9.04 using Ruby. I translated and followed all the steps outlined in getting OSX talking to SQL Server from here:
http://toolmantim.com/articles/getting_rails_talking_to_sqlserver_on_osx_via_odbc
Everything is working on the FreeTDS and unixODBC end. I can see and query the database using tsql.
When I try to access the database from Ruby using IRB I get the following error:
DBI::DatabaseError : INTERN (0) [RubyODBC] Cannot allocate SQLHENV
Has anyone run into this and what can I do to solve this?
I started getting this error when I upgraded to Ubuntu 9.10 (Karmic Koala). Your tip regarding installation order of the Ubuntu packages didn't work for me.
It seems the fix was to manually compile ruby-odbc.
wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-dlopen
make
sudo make install
System
Ubuntu 9.10 64 bit
I had to specify the odbc directory in the rubyodbc install
wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-odbc-dir=/usr/lib/odbc --disable-dlopen
make
sudo make install
I had the same problem.
But on Centos 5.5 not Ubuntu
Tried many forums/solutions with no joy.
The error message hints at a missing reference to unixODBC.
Which was setting using LD_LIBRARY_PATH variable.
Found another way to set path, by creating
/etc/ld.so.conf.d/odbc.conf.
add unixODBC location to file ie /usr/local/lib.
Run, sudo ldconfig.
Go fig that I actually got this working after submitting my question. What I ended up doing was uninstall libdbd-odbc-ruby and libdbi-ruby and then reinstalling them by installing libdbi-ruby first and then installing libdbd-odbc-ruby. I guess when I installed them before, something must of messed up.
BTW, following the instructions to recompile Ruby-ODBC on Ubuntu 9.10 (Karmic) required installation of either the libiodbc2-dev or the unixodbc-dev package. When using libiodbc2-dev, I got segmentation faults when my Ruby program tried:
connection.select_all('select top 15 * from log_device_healths')
..but no problem when using unixodbc-dev instead.
Tim Morgan's solution didn't work for me. However I was able to get things working by installing an older version of libodbc-ruby (0.9995) from here:
http://mirrors.kernel.org/ubuntu/pool/universe/libo/libodbc-ruby/libodbc-ruby1.8_0.9995-1_i386.deb
Additional details are available from Carsten Gehling's blog:
http://gehling.dk/2010/02/the-woes-of-libodbc-ruby1-8-and-debian-ubuntu/
Be careful though -- Ubuntu's Update Manager will happily "upgrade" this version of libodbc-ruby to the broken 0.9997-2. I accidentally overwrote the older version this way only to end up back here, trying to figure out how I fixed it last time.
Well, it seems my other answer stopped working for me. This thread helped me to solve the issue in another way, and I wanted to share it here.
sudo gem uninstall ruby-odbc
sudo rm /usr/local/lib/site_ruby/1.8/x86_64-linux/odbc.so
cd /tmp
wget http://mirrors.kernel.org/ubuntu/pool/universe/libo/libodbc-ruby/libodbc-ruby1.8_0.9995-1_amd64.deb
sudo dpkg -i libodbc-ruby1.8_0.9995-1_amd64.deb
If you're not on a 64-bit platform, you'll need to download a different Debian package.
Basically, what solves the problem is installing version 0.9995 of the ruby-odbc Ubuntu package.