Paperclip: "is not recognized by the 'identify' command" - ruby-on-rails

I've found a couple of other related questions but none of the answers are working for me as I'm using a Windows machine to develop.
Everything is configured and setup correctly as far as I know and right now the only problem I'm getting is the following: http://i.imgur.com/v3BLS.png
Seeing that I'm a windows user, I've installed ImageMagick and ran the which identify command to give me the identify path to place in my development.rb:
Paperclip.options[:command_path] = "/c/Program Files/ImageMagick-6.7.1-Q16/identify"
Anyone have an idea why I am getting this error still?
EDIT: Might the fact that my file variable is called photo_1 have anything to do with it? Should I just use photo instead?

I guess the problem is the command path.
Contrary to what you did, it should point to a folder not a precise binary.
Try:
Paperclip.options[:command_path] = "c:\Program Files\ImageMagick-6.7.1-Q16\"

This is the only solution which saved my day after trying all the above and a lot more
Image file is not recognized by the 'identify' command. (heroku)

Related

Psych Error: `parse': (<unknown>): could not find expected

`':' while scanning a simple key at line 16 column 1(Psych::SyntaxError)
I'm working on a Rails application tutorial and have had the above error come up several times. When I was getting this error it seemed to only be a problem if I used one particular terminal window. I have since restarted the computer and now it is a problem regardless of what I do.
I went to the project on github and copied the information in 'secrets.yml' into my file in case that was the issue but doesn't help. In fact I'm not sure if that is even the file causing the problem because when I shift the code in that file and save it I still get the same error; at those times it points to a line that is now blank in the 'secrets.yml'
Update.
now I am getting this when i run this command
rails generate simple_form:install --foundation
-bash: $: command not found.
only change I did was start the code in 'secrets.yml' lower down, and i added a secret key to my .bash_profile, as it was suggested in tutorial and I had not done it before, and thought that might be the problem.
Update 2
shut down terminal and tied again and getting the original problem "psyche Error" Yes, thank you for your feedback, I too, although not sure why, suspect it is to do with the 'secret' file or could it be changes the tutorial told me to make to my .bash_profile. The instructions were not very clear, wondering if that is where I messed up. If that is so then I would not know how to fix that.
The Psych gem is the wrapper around libyaml and used within Ruby's YAML class, so it's not surprising you think it could be the 'secrets.yml'; a YAML config file. I'd stay the course and find what isn't being formatted correctly.

Paperclip::Errors::NotIdentifiedByImageMagickError on Windows 7

I'm going through Mattan Griffel's "One Month Rails" (http://onemonthrails.com/) class. I'm trying to use the paperclip gem to upload images. Initial install and usage went fine, until he added a line to reduce the size of images. This was placed in app/models/pin.rb as shown in his tutorial:
has_attached_file :image, styles: { medium: "320x240>" }
It worked until the styles: {} part was added. I have also updated my partial to pass in the :medium method.
I'm using: paperclip (3.4.1),cocaine (0.5.1) and rails (3.2.12). I have seen other posts where this was fixed with homebrew, but I'm on a Windows 7 machine and I'm fairly certain that doesn't apply. Let me know if I need to post anything else.
I'm following the same course. After several gem changes (trying older versions of cocaine, etcetera...) the thing that solved my problem was adding this line to pin.rb:
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.5-Q16'
before belongs_to :user
(change the path for your image magick install path)
After this, run a bundle update and reset your rails server.
Add
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.9-Q16'
to this file.
\config\environments\development.rb
Make sure to run
which convert
so you know what version number and don't copy and paste another version number.
Restart your rails server
Though it showed the path when I ran which convert, I download the ImageMagick and installed it separately and gave the path and added the line as mentioned by q256 and it worked!
I was using version 6.7.9 of ImageMagick. So in addition to adding the command_path, I had to update to the latest version of ImageMagick i.e 6.8.8
Just to expand on q256's answer, updating this file might cause it to break on heroku when you do a push, because the live-on-the-internet server won't know how to find a program installed on your local hard drive.
The more correct way (at least that I have found) to fix this issue for windows users is to update the development.rb file under config->environments->development.rb and throw the line in at the end of the file.
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.5-Q16'
Hope that helps someone, and don't forget to restart your rails server after saving the file, note that a bundle update isn't required.

Generating file with PDFKit on Heroku - No such file or directory

I'm using PDFKit to create pdfs of from a given url within a Resque job on Heroku Cedar. My code looks like:
kit = PDFKit.new(url)
pdf = kit.to_file("/tmp/#{SecureRandom.hex}.pdf")
I then upload the file using fog to S3 for permanent storage. This job usually works, but also fails maybe a third of the time with:
No such file or directory - /tmp/a05c165fc80878b75fd15c447695de71.pdf
Manually running through the code in console will produce the same error.
According to the Heroku docs, I should be able to write a temporary file anywhere in the app's directory on Cedar. I've tried creating the tmp directory first (in console) but that didn't seem to change anything. Neither did saving to "#{Rails.root}/tmp/#{SecureRandom.hex}.pdf".
Any ideas would be greatly appreciated.
UPDATE
The full error in console is:
Error: Failed loading page http://grist.org/living/you-look-great-in-green-clothing-industry-gets-a-makeover-maybe.html
(sometimes it will work just to ignore this error with --load-error-handling ignore)
Errno::ENOENT: No such file or directory - /tmp/55a1d418074736decfd4e123d8e2bba2.pdf
It seems that maybe this is an error coming from wkhtmltopdf, however, I'm not sure where to add this flag if I'm using wkhtmltopdf via PDFkit.
Looks like the solution, as the error I posted second suggested, was to ignore the load error. I did this with:
PDFKit.configure do |config|
config.default_options[:load_error_handling] = 'ignore'
end
I wasn't seeing this warning at first because Resque was only showing me the final error. Thanks #ctshryock, your question made me think a little more about exactly where this error was coming from.

Displaying image generated by Paperclip in Rails app

I am able to display image generated by Paperclip in Rails app, at DEVELOPMENT env,
E.g http://localhost:3000/system/shot/sample.png
However upon I migrate to PRODUCTION, http://xyz/system/shot/sample.png is not recognized. I am using Passanger running on Apache. Is there any config that I need to setup at prod env?
And I've verified the physical folder and file exits at prod machine.
Note: i just check the production.log , and herewith the error
**ActionController::RoutingError (No route matches [GET] "/system/shot/sample.png"):**
Looking at the error above, likely I need to do something in route.rb ; but strangely i am using same route.rb in DEV , and it works..
Thanks in advance.
do something like which convert and it should print out something. if there is nothing, then you know you need imagemagick.
Check that your imagemagick on your slice is set up to serve png's and jpgs too, while you are at it.
I use Gentoo and the built in package manager use flags turn off that stuff, so my pngs never showed.
sorry, it is false alarm, the image file was not yet created initially.

Rubys on Rails project Using Aptana

I am having a major issue with creating a Rails Project on Aptana (using mac os x). Basically, when i try starting a Rails project and name a file, it comes back with an error saying:
"!!! Path to log file not valid: /Users/fab/Documents/Aptana Studio Workspace/test.rb/log/mongrel.log mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help."
and then a pop up comes up saying: "Rename the directory to no longer have a space"
After all this, i tried renaming the directory without spaces, but then when i went back to create a new project again it came back with this pop up that says "resource'/fab/public'does not exist." Under this there is a list of two options: "periodic workshop save" and "replace project index file."
What does this mean, and how can i fix the problem?
Any advise would be much appreciated!
Omarj
Mongrel used to have a bug with writing log files, and for whatever reason it's trying to create a path relative to a file (rather than a folder) in your case. i think they also had issues with spaces in the path.
Do NOT rename your workspace path, or Studio/RadRails won't see the files anymore (as you saw above) - because you moved them.
I suggest renaming the folder back. This question is pretty stale, so mongrel is no longer widely used. you could try one of the other server types, like webrick.
Hey, I don't have an answer to your question. However, would advise you that if you are starting to get your hands dirty with Ruby and Rails, then consider TextMate as your IDE instead of RadRails.

Resources